# `RDF.NQuads.Encoder`
[🔗](https://github.com/rdf-elixir/rdf-ex/blob/v3.0.1/lib/rdf/serializations/nquads/encoder.ex#L1)

An encoder for N-Quads serializations of RDF.ex data structures.

As for all encoders of `RDF.Serialization.Format`s, you normally won't use these
functions directly, but via one of the `write_` functions on the `RDF.NQuads`
format module or the generic `RDF.Serialization` module.

## Options

- `:default_graph_name`: The graph name to be used as the default for triples
  from a `RDF.Graph` or `RDF.Description`. When the input to be encoded is a
  `RDF.Description` the default is `nil` for the default graph. In case of a
  `RDF.Graph` the default is the `RDF.Graph.name/1`. The option doesn't
  have any effect at all when the input to be encoded is a `RDF.Dataset`.
- `:sort`: Boolean flag which specifies if the encoded statements should
  be sorted into Unicode code point order (default: `false`).
  This option is available only on `encode/2`.
- `:mode`: Allows to specify if the encoded statements should be emitted as
  strings or IO lists using the value `:string` or `:iodata` respectively
  (default: `:string`). This option is available only on `stream/2`.

# `encode`

```elixir
@spec encode(
  RDF.Data.Source.t(),
  keyword()
) :: {:ok, String.t()} | {:error, any()}
```

Encodes the given RDF data in N-Quads format.

See module documentation for available options.

# `iolist_statement`

```elixir
@spec iolist_statement(RDF.Statement.t(), RDF.Statement.graph_name()) :: iolist()
```

# `iolist_term`

# `statement`

```elixir
@spec statement(RDF.Statement.t(), RDF.Statement.graph_name()) :: String.t()
```

# `stream`

```elixir
@spec stream(
  RDF.Data.Source.t(),
  keyword()
) :: Enumerable.t()
```

Encodes the given RDF data into a stream of N-Quads.

See module documentation for available options.

# `term`

---

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