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

A behaviour for RDF serialization formats.

A serialization format can be implemented like this

    defmodule SomeFormat do
      use RDF.Serialization.Format
      import RDF.Sigils

      @id         ~I<http://example.com/some_format>
      @name       :some_format
      @extension  "ext"
      @media_type "application/some-format"
    end

When `@id`, `@name`, `@extension` and `@media_type` module attributes are
defined the resp. behaviour functions are generated automatically and return
these values.

Then you'll have to do the main work by implementing a
`RDF.Serialization.Encoder` and a `RDF.Serialization.Decoder` for the format.

By default, it is assumed that these are defined in `Encoder` and `Decoder`
modules under the `RDF.Serialization.Format` module of the format, i.e. in the
example above in `SomeFormat.Encoder` and `SomeFormat.Decoder`. If you want
them in another module, you'll have to override the `encoder/0` and/or
`decoder/0` functions in your `RDF.Serialization.Format` module.

# `decoder`

```elixir
@callback decoder() :: module()
```

The `RDF.Serialization.Decoder` module for the serialization format.

# `encoder`

```elixir
@callback encoder() :: module()
```

The `RDF.Serialization.Encoder` module for the serialization format.

# `extension`

```elixir
@callback extension() :: String.t()
```

The usual file extension for the serialization format.

# `id`

```elixir
@callback id() :: RDF.IRI.t()
```

An IRI of the serialization format.

# `media_type`

```elixir
@callback media_type() :: String.t()
```

The MIME type of the serialization format.

# `name`

```elixir
@callback name() :: atom()
```

The name atom of the serialization format.

---

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