pub trait TermDecoder<TEncoding: TermEncoding + ?Sized>:
Debug
+ Sync
+ Send {
type Term<'data>;
// Required methods
fn decode_terms(
array: &TEncoding::Array,
) -> impl Iterator<Item = ThinResult<Self::Term<'_>>>;
fn decode_term(scalar: &TEncoding::Scalar) -> ThinResult<Self::Term<'_>>;
}
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§
Required Methods§
Sourcefn decode_terms(
array: &TEncoding::Array,
) -> impl Iterator<Item = ThinResult<Self::Term<'_>>>
fn decode_terms( array: &TEncoding::Array, ) -> impl Iterator<Item = ThinResult<Self::Term<'_>>>
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.
Sourcefn decode_term(scalar: &TEncoding::Scalar) -> ThinResult<Self::Term<'_>>
fn decode_term(scalar: &TEncoding::Scalar) -> ThinResult<Self::Term<'_>>
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§
Source§impl TermDecoder<PlainTermEncoding> for DefaultPlainTermDecoder
Extracts a sequence of term references from the given array.
impl TermDecoder<PlainTermEncoding> for DefaultPlainTermDecoder
Extracts a sequence of term references from the given array.
Source§impl TermDecoder<PlainTermEncoding> for GraphNameRefPlainTermDecoder
Extracts a sequence of term references from the given array.
impl TermDecoder<PlainTermEncoding> for GraphNameRefPlainTermDecoder
Extracts a sequence of term references from the given array.