RDF.Serialization.Format behaviour (RDF.ex v0.9.1) View Source

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.

Link to this section Summary

Callbacks

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

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

The usual file extension for the serialization format.

An IRI of the serialization format.

The MIME type of the serialization format.

An name atom of the serialization format.

Link to this section Callbacks

Specs

decoder() :: module()

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

Specs

encoder() :: module()

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

Specs

extension() :: String.t()

The usual file extension for the serialization format.

Specs

id() :: RDF.IRI.t()

An IRI of the serialization format.

Specs

media_type() :: String.t()

The MIME type of the serialization format.

Specs

name() :: atom()

An name atom of the serialization format.