RDF.Serialization.Writer (RDF.ex v0.9.0) View Source

General functions for writing the statements of a RDF.Graph or RDF.Dataset to a serialization file or string.

You probably won't use these functions directly, but instead use the automatically generated functions with same name on a RDF.Serialization.Format, which implicitly use the proper RDF.Serialization.Encoder module.

Link to this section Summary

Functions

Encodes and writes a graph or dataset to a file.

Encodes and writes a graph or dataset to a file.

Encodes and writes a graph or dataset to a string.

Encodes and writes a graph or dataset to a string.

Link to this section Functions

Link to this function

write_file(encoder, data, path, opts \\ [])

View Source

Specs

write_file(module(), RDF.Graph.t() | RDF.Dataset.t(), Path.t(), keyword()) ::
  :ok | {:error, any()}

Encodes and writes a graph or dataset to a file.

General available serialization-independent options:

  • :force - If not set to true, an error is raised when the given file already exists (default: false)
  • :file_mode - A list with the Elixir File.open modes to be used for writing (default: [:write, :exclusive])

It returns :ok if successful or {:error, reason} if an error occurs.

Link to this function

write_file!(encoder, data, path, opts \\ [])

View Source

Specs

write_file!(module(), RDF.Graph.t() | RDF.Dataset.t(), Path.t(), keyword()) ::
  :ok

Encodes and writes a graph or dataset to a file.

See write_file for a list of available options.

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

Link to this function

write_string(encoder, data, opts \\ [])

View Source

Specs

write_string(module(), RDF.Graph.t() | RDF.Dataset.t(), keyword()) ::
  {:ok, String.t()} | {:error, any()}

Encodes and writes a graph or dataset to a string.

It returns an {:ok, string} tuple, with string being the serialized graph or dataset, or {:error, reason} if an error occurs.

Link to this function

write_string!(encoder, data, opts \\ [])

View Source

Specs

write_string!(module(), RDF.Graph.t() | RDF.Dataset.t(), keyword()) ::
  String.t()

Encodes and writes a graph or dataset to a string.

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