TermDecoder

Trait TermDecoder 

Source
pub trait TermDecoder<TEncoding>:
    Debug
    + Sync
    + Send
where TEncoding: TermEncoding + ?Sized,
{ type Term<'data>; // Required methods fn decode_terms( array: &<TEncoding as TermEncoding>::Array, ) -> impl Iterator<Item = Result<Self::Term<'_>, ThinError>>; fn decode_term( scalar: &<TEncoding as TermEncoding>::Scalar, ) -> Result<Self::Term<'_>, ThinError>; }
Expand description

Allows extracting an iterator of a type from an EncodingArray.

This allows uesrs to access the inner values of an RDF term array. It allows one to obtain a typed iterator over the RDF terms in the array. A decoder is specialized for one encoding and one value type (Self::Term).

§Compatibility

Decoders are allowed to only support a subset of the encoded RDF terms. For example, a decoder for boolean values may produce an error if it encounters a literal with a different type. However, it is recommended that there is one decoder per TermEncoding that allows users to extract all RDF terms.

§Performance

Using a TermDecoder for accessing the array, performing an operation on Self::Term, and then re-encoding the resulting value using a TermEncoder may incur a performance penalty. However, we hope that this impact can be mitigated by compiler optimizations. We have yet to benchmark this impact to make a founded recommendation of when to use decoders and encoders. Users are free to directly work on the Arrow arrays to side-step the typed Encoding/Decoding machinery.

Required Associated Types§

Source

type Term<'data>

The resulting value type of decoding an RDF term.

Required Methods§

Source

fn decode_terms( array: &<TEncoding as TermEncoding>::Array, ) -> impl Iterator<Item = Result<Self::Term<'_>, ThinError>>

Allows extracting an iterator over all RDF terms in array that are compatible with this decoder (see TermDecoder for more information).

The creation of the iterator cannot fail by itself, as the invariants of the encodings should have been checked while creating array. However, the iterator may return an error on every new value. This could be due to the value being incompatible with the decoder.

Source

fn decode_term( scalar: &<TEncoding as TermEncoding>::Scalar, ) -> Result<Self::Term<'_>, ThinError>

Allows extracting an iterator over all RDF terms in array that are compatible with this decoder (see TermDecoder for more information).

The creation of the value can fail if the value stored in the scalar is incompatible with this decoder.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§