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

An encoder for N-Triples 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.NTriples`
format module or the generic `RDF.Serialization` module.

# `encode`

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

Encodes the given RDF data in N-Triples format.

## Options

- `:sort`: Boolean flag which specifies if the encoded triples should
  be sorted into Unicode code point order (Default: `false`)

# `iolist_statement`

```elixir
@spec iolist_statement(RDF.Triple.t()) :: iolist()
```

# `iolist_term`

```elixir
@spec iolist_term(RDF.Term.t()) :: String.t()
```

# `statement`

```elixir
@spec statement(RDF.Triple.t()) :: String.t()
```

# `stream`

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

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

## Options

- `: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`)

# `term`

```elixir
@spec term(RDF.Term.t()) :: String.t()
```

---

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