View Source RDF.Serialization.Format behaviour (RDF.ex v1.2.0)

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.

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.

The name atom of the serialization format.

Callbacks

@callback decoder() :: module()

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

@callback encoder() :: module()

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

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

The usual file extension for the serialization format.

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

An IRI of the serialization format.

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

The MIME type of the serialization format.

@callback name() :: atom()

The name atom of the serialization format.