# `RDF.Serialization.Decoder`
[🔗](https://github.com/rdf-elixir/rdf-ex/blob/v3.0.1/lib/rdf/serialization/decoder.ex#L1)

A behaviour for decoders of strings encoded in a specific `RDF.Serialization` format.

# `decode`

```elixir
@callback decode(String.t()) :: {:ok, RDF.Graph.t() | RDF.Dataset.t()} | {:error, any()}
```

Decodes a serialized `RDF.Graph` or `RDF.Dataset` from a string.

It returns an `{:ok, data}` tuple, with `data` being the deserialized graph or
dataset, or `{:error, reason}` if an error occurs.

# `decode`

```elixir
@callback decode(
  String.t(),
  keyword()
) :: {:ok, RDF.Graph.t() | RDF.Dataset.t()} | {:error, any()}
```

Decodes a serialized `RDF.Graph` or `RDF.Dataset` from a string.

It returns an `{:ok, data}` tuple, with `data` being the deserialized graph or
dataset, or `{:error, reason}` if an error occurs.

# `decode!`

```elixir
@callback decode!(String.t()) :: RDF.Graph.t() | RDF.Dataset.t()
```

Decodes a serialized `RDF.Graph` or `RDF.Dataset` from a string.

As opposed to `decode/2`, it raises an exception if an error occurs.

Note: The `__using__` macro automatically provides an overridable default
implementation based on the non-bang `decode` function.

# `decode!`

```elixir
@callback decode!(
  String.t(),
  keyword()
) :: RDF.Graph.t() | RDF.Dataset.t()
```

Decodes a serialized `RDF.Graph` or `RDF.Dataset` from a string.

As opposed to `decode/2`, it raises an exception if an error occurs.

Note: The `__using__` macro automatically provides an overridable default
implementation based on the non-bang `decode` function.

# `decode_from_stream`
*optional* 

```elixir
@callback decode_from_stream(
  Enumerable.t(),
  keyword()
) :: {:ok, RDF.Graph.t() | RDF.Dataset.t()} | {:error, any()}
```

Decodes a serialized `RDF.Graph` or `RDF.Dataset` from a stream.

It returns an `{:ok, data}` tuple, with `data` being the deserialized graph or
dataset, or `{:error, reason}` if an error occurs.

# `decode_from_stream!`
*optional* 

```elixir
@callback decode_from_stream!(
  Enumerable.t(),
  keyword()
) :: RDF.Graph.t() | RDF.Dataset.t()
```

Decodes a serialized `RDF.Graph` or `RDF.Dataset` from a stream.

As opposed to `decode_from_stream/2`, it raises an exception if an error occurs.

Note: The `__using__` macro automatically provides an overridable default
implementation based on the non-bang `decode` function.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
