← All compilation units

Flyology_RDF.Codecs

Description

Compact binary encoding for terms and statements.

This exists for callers that need to put a term in a cache, a key, or a message and want something smaller and faster to compare than a serialization meant for people.

The encoding is injective by construction rather than by inspection: every value begins with a tag naming its kind, and every variable-length field carries its length, so no two distinct terms can produce the same bytes and no field boundary depends on scanning for a delimiter. That is the property the whole thing is for, and it is what the golden vectors in the tests defend.

> The format is EXPERIMENTAL. It is versioned, and the version will be > raised rather than the bytes quietly changed, but it is not yet a > compatibility commitment: the question of whether blank node identity > belongs in a portable encoding at all is not settled, and settling it > after promising stability would mean an immediate second version.

Decode_Quad

function Decode_Quad (Bytes : String) return Quads.Quad

Decode a statement, which must occupy the whole of Bytes.

Parameters
Bytes

Encoded statement

Return value

The decoded statement

Raised exceptions
Invalid_Encoding

Bytes are malformed, truncated, or carry trailing input

Decode_Term

function Decode_Term (Bytes : String) return Terms.Term

Decode a term, which must occupy the whole of Bytes.

Parameters
Bytes

Encoded term

Return value

The decoded term

Raised exceptions
Invalid_Encoding

Bytes are malformed, truncated, or carry trailing input

Encode

function Encode (Value : Quads.Quad) return String

Encode a statement.

Parameters
Value

Statement to encode

Return value

The encoded bytes

Encode

function Encode (Value : Terms.Term) return String

Encode a term.

Parameters
Value

Term to encode

Return value

The encoded bytes

Format_Identifier

Format_Identifier : constant String := "flyology-rdf-binary-v1";

Identifies the encoding, for callers that store or transmit it.

Invalid_Encoding

Invalid_Encoding : exception;

Raised when bytes are not a valid encoding, including when they are well formed but describe a term this crate will not build.