View Source RDF.Serialization.Encoder behaviour (RDF.ex v2.0.1)

A behaviour for encoders of RDF data structures in a specific RDF.Serialization format.

Summary

Callbacks

Serializes an RDF data structure into a string.

Serializes an RDF data structure into a string.

Serializes an RDF data structure into a string.

Serializes an RDF data structure into a string.

Serializes an RDF data structure into a stream.

Callbacks

@callback encode(RDF.Data.t()) :: {:ok, String.t()} | {:error, any()}

Serializes an RDF data structure into a string.

It should return an {:ok, string} tuple, with string being the serialized RDF data structure, or {:error, reason} if an error occurs.

@callback encode(
  RDF.Data.t(),
  keyword()
) :: {:ok, String.t()} | {:error, any()}

Serializes an RDF data structure into a string.

It should return an {:ok, string} tuple, with string being the serialized RDF data structure, or {:error, reason} if an error occurs.

@callback encode!(RDF.Data.t()) :: String.t()

Serializes an RDF data structure into a string.

As opposed to encode, it raises an exception if an error occurs.

Note: The __using__ macro automatically provides an overridable default implementation based on the non-bang encode function.

@callback encode!(
  RDF.Data.t(),
  keyword()
) :: String.t()

Serializes an RDF data structure into a string.

As opposed to encode, it raises an exception if an error occurs.

Note: The __using__ macro automatically provides an overridable default implementation based on the non-bang encode function.

Link to this callback

stream(t, keyword)

View Source (optional)
@callback stream(
  RDF.Data.t(),
  keyword()
) :: Enumerable.t()

Serializes an RDF data structure into a stream.

It should return a stream emitting either strings or iodata of the serialized RDF data structure. If both forms are supported the form should be configurable via the :mode option and its values :string respective :iodata.