Module sophia_api::triple::streaming_mode [−][src]
Expand description
Streaming modes for triple iterators and triple streams.
What this is about
The Graph
traits provides a number of methods for iterating over Triple
s,
as for example the Graph::triples
method.
Since Triple
is itself a trait,
the actual type returned by such iterating methods needs to be specified for each
Graph
implementation.
This is what this module is about.
In the future, the ideal solution
Ideally, the concrete type of Triple
s returned by iterating methods
would be directly given by the Graph::Triple
associated type.
Unfortunately, in the current version of Rust,
this is not practical:
in many implementations, iterating methods would return references
to triples that are actually owned by the graph itself.
But the associated type Graph::Triple
can not be a reference type,
because the lifetime of such references can not be specified once and for all.
The ideal solution to this problem would be Generic Associated Types (GAT), but until those are stabilized, we need another solution.
In the meantime, the workaround
The associated type Graph::Triple
is not a type implementing the Triple
trait,
it is one of the possible TripleStreamingMode
s provided by this module
(see below).
Then iterating methods are restricted to returning a particular version of
[StreamedTriple<'a>
], satisfying the given streaming mode.
The available streaming mode are:
ByValue
<T>
: [StreamedTriple<'a>
] will wrap an (owned) instance ofT
; it is constructed withStreamedTriple::by_value
;ByRef
<T>
: [StreamedTriple<'a>
] will wrap a reference toT
, valid as long as'a
; it is constructed withStreamedTriple::by_ref
;ByTermRefs
<T>
:StreamedTriple
<'a>
will wrap an array of 3 [&'a T
] references, valid as long as'a
; it is constructed withStreamedTriple::by_term_refs
.
In addition, the macro make_scoped_triple_streaming_mode
allows to create a streaming mode for any lifetime-parameterized type implementing
Triple
(see its documentation for more details).
NB: actually, another mode exists,
but is specifically designed for the dataset::adapter
,
should never be needed in other contexts.
Structs
Traits
A utility trait used internally by make_scoped_triple_streaming_mode
.
It should not be implemented manually.
See module documentation.