pub trait TripleSource {
type Triple<'x>: Triple;
type Error: Error + 'static;
// Required method
fn try_for_some_triple<E, F>(
&mut self,
f: F,
) -> StreamResult<bool, Self::Error, E>
where E: Error,
F: FnMut(Self::Triple<'_>) -> Result<(), E>;
// Provided methods
fn try_for_each_triple<F, E>(
&mut self,
f: F,
) -> StreamResult<(), Self::Error, E>
where F: FnMut(Self::Triple<'_>) -> Result<(), E>,
E: Error { ... }
fn for_some_triple<F>(&mut self, f: &mut F) -> Result<bool, Self::Error>
where F: FnMut(Self::Triple<'_>) { ... }
fn for_each_triple<F>(&mut self, f: F) -> Result<(), Self::Error>
where F: FnMut(Self::Triple<'_>) { ... }
fn filter_triples<F>(self, predicate: F) -> FilterTripleSource<Self, F>
where Self: Sized,
F: FnMut(&Self::Triple<'_>) -> bool { ... }
fn filter_map_triples<F, T>(
self,
filter_map: F,
) -> FilterMapTripleSource<Self, F>
where Self: Sized,
F: FnMut(Self::Triple<'_>) -> Option<T> { ... }
fn map_triples<F, T>(self, map: F) -> MapTripleSource<Self, F>
where Self: Sized,
F: FnMut(Self::Triple<'_>) -> T { ... }
fn to_quads(self) -> ToQuads<Self>
where Self: Sized { ... }
fn size_hint_triples(&self) -> (usize, Option<usize>) { ... }
fn collect_triples<G>(
self,
) -> StreamResult<G, Self::Error, <G as Graph>::Error>
where Self: Sized,
for<'x> Self::Triple<'x>: Triple,
G: CollectibleGraph { ... }
fn add_to_graph<G: MutableGraph>(
self,
graph: &mut G,
) -> StreamResult<usize, Self::Error, <G as MutableGraph>::MutationError>
where Self: Sized,
for<'x> Self::Triple<'x>: Triple { ... }
}
Expand description
A triple source produces triples, and may also fail in the process.
see module documentation for the rationale of his trait.
§Common implementors
Any iterator yielding results of Triple
implements the TripleSource
trait.
Any iterator of Triple
can also be converted to an Infallible
TripleSource
thanks to the IntoTripleSource
extension trait.
Required Associated Types§
Required Methods§
Sourcefn try_for_some_triple<E, F>(
&mut self,
f: F,
) -> StreamResult<bool, Self::Error, E>
fn try_for_some_triple<E, F>( &mut self, f: F, ) -> StreamResult<bool, Self::Error, E>
Call f for some triple(s) (possibly zero) from this source, if any.
Return Ok(false)
if there are no more triples in this source.
Return an error if either the source or f
errs.
Provided Methods§
Sourcefn try_for_each_triple<F, E>(
&mut self,
f: F,
) -> StreamResult<(), Self::Error, E>
fn try_for_each_triple<F, E>( &mut self, f: F, ) -> StreamResult<(), Self::Error, E>
Call f for all triples from this source.
Return an error if either the source or f
errs.
Sourcefn for_some_triple<F>(&mut self, f: &mut F) -> Result<bool, Self::Error>
fn for_some_triple<F>(&mut self, f: &mut F) -> Result<bool, Self::Error>
Call f for some triple(s) (possibly zero) from this source, if any.
Return false if there are no more triples in this source.
Return an error if either the source errs.
Sourcefn for_each_triple<F>(&mut self, f: F) -> Result<(), Self::Error>
fn for_each_triple<F>(&mut self, f: F) -> Result<(), Self::Error>
Call f for all triples from this source.
Return an error if either the source errs.
Sourcefn filter_triples<F>(self, predicate: F) -> FilterTripleSource<Self, F>
fn filter_triples<F>(self, predicate: F) -> FilterTripleSource<Self, F>
Returns a source which uses predicate
to determine if an triple should be yielded.
Sourcefn filter_map_triples<F, T>(
self,
filter_map: F,
) -> FilterMapTripleSource<Self, F>
fn filter_map_triples<F, T>( self, filter_map: F, ) -> FilterMapTripleSource<Self, F>
Returns a source that both filters and maps.
See also TripleSource::filter_triples
and TripleSource::map_triples
.
Sourcefn map_triples<F, T>(self, map: F) -> MapTripleSource<Self, F>
fn map_triples<F, T>(self, map: F) -> MapTripleSource<Self, F>
Returns a source which yield the result of map
for each triple.
See also TripleSource::to_quads
.
NB: due to some limitations in GATs (Generic) Associated Types,
the map
function is currently restricted in what it can return.
In particular, passing functions as trivial as |t| t
or |t| t.to_spo()
currently do not compile on all implementations of TripleSource
.
Furthermore, some functions returning a Triple
are accepted,
but fail to make the resulting map::MapTripleSource
recognized as a TripleSource
.
As a rule of thumb,
whenever map
returns something satisfying the 'static
lifetime,
things should work as expected.
Sourcefn to_quads(self) -> ToQuads<Self>where
Self: Sized,
fn to_quads(self) -> ToQuads<Self>where
Self: Sized,
Convert of triples in this source to quads (belonging to the default graph).
Sourcefn size_hint_triples(&self) -> (usize, Option<usize>)
fn size_hint_triples(&self) -> (usize, Option<usize>)
Returns the bounds on the remaining length of the source.
This method has the same contract as Iterator::size_hint
.
Sourcefn collect_triples<G>(self) -> StreamResult<G, Self::Error, <G as Graph>::Error>
fn collect_triples<G>(self) -> StreamResult<G, Self::Error, <G as Graph>::Error>
Collect these triples into a new graph.
Sourcefn add_to_graph<G: MutableGraph>(
self,
graph: &mut G,
) -> StreamResult<usize, Self::Error, <G as MutableGraph>::MutationError>
fn add_to_graph<G: MutableGraph>( self, graph: &mut G, ) -> StreamResult<usize, Self::Error, <G as MutableGraph>::MutationError>
Insert all triples from this source into the given MutableGraph.
Stop on the first error (in the source or in the graph).
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.