TripleSource

Trait TripleSource 

Source
pub trait TripleSource: Source + IsTripleSource {
    // Provided methods
    fn try_for_some_triple<E, F>(
        &mut self,
        f: F,
    ) -> StreamResult<bool, Self::Error, E>
       where E: Error + Send + Sync + 'static,
             F: FnMut(TSTriple<'_, Self>) -> Result<(), E> { ... }
    fn try_for_each_triple<F, E>(
        &mut self,
        f: F,
    ) -> StreamResult<(), Self::Error, E>
       where F: FnMut(TSTriple<'_, Self>) -> Result<(), E>,
             E: Error + Send + Sync + 'static { ... }
    fn for_some_triple<F>(&mut self, f: F) -> Result<bool, Self::Error>
       where F: FnMut(TSTriple<'_, Self>) { ... }
    fn for_each_triple<F>(&mut self, f: F) -> Result<(), Self::Error>
       where F: FnMut(TSTriple<'_, Self>) { ... }
    fn filter_triples<'f, F>(
        self,
        predicate: F,
    ) -> FilterTripleSource<Self, impl FnMut(&Self::Item<'_>) -> bool + 'f>
       where Self: Sized,
             F: FnMut(&TSTriple<'_, Self>) -> bool + 'f { ... }
    fn filter_map_triples<'f, F, T>(
        self,
        filter_map: F,
    ) -> FilterMapSource<Self, impl FnMut(Self::Item<'_>) -> Option<T> + 'f>
       where Self: Sized,
             F: FnMut(TSTriple<'_, Self>) -> Option<T> + 'f { ... }
    fn map_triples<'m, F, T>(
        self,
        map: F,
    ) -> MapSource<Self, impl FnMut(Self::Item<'_>) -> T + 'm>
       where Self: Sized,
             F: FnMut(TSTriple<'_, Self>) -> T + 'm { ... }
    fn size_hint_triples(&self) -> (usize, Option<usize>) { ... }
    fn to_quads(self) -> ToQuads<Self>
       where Self: Sized { ... }
    fn collect_triples<G>(
        self,
    ) -> StreamResult<G, Self::Error, <G as Graph>::Error>
       where Self: Sized,
             G: CollectibleGraph { ... }
    fn add_to_graph<G: MutableGraph>(
        self,
        graph: &mut G,
    ) -> StreamResult<usize, Self::Error, <G as MutableGraph>::MutationError>
       where Self: Sized { ... }
}
Expand description

A triple source is a Source producing triples.

This trait extends the Source trait with triple-specific methods.

It does not need to be explicitly implemented: any Source implementation producing triples will automatically implement TripleSource.

See also TSTriple.

Provided Methods§

Source

fn try_for_some_triple<E, F>( &mut self, f: F, ) -> StreamResult<bool, Self::Error, E>
where E: Error + Send + Sync + 'static, F: FnMut(TSTriple<'_, Self>) -> Result<(), 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.

Source

fn try_for_each_triple<F, E>( &mut self, f: F, ) -> StreamResult<(), Self::Error, E>
where F: FnMut(TSTriple<'_, Self>) -> Result<(), E>, E: Error + Send + Sync + 'static,

Call f for all triples from this source.

Return an error if either the source or f errs.

Source

fn for_some_triple<F>(&mut self, f: F) -> Result<bool, Self::Error>
where F: FnMut(TSTriple<'_, Self>),

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.

Source

fn for_each_triple<F>(&mut self, f: F) -> Result<(), Self::Error>
where F: FnMut(TSTriple<'_, Self>),

Call f for all triples from this source.

Return an error if either the source errs.

Source

fn filter_triples<'f, F>( self, predicate: F, ) -> FilterTripleSource<Self, impl FnMut(&Self::Item<'_>) -> bool + 'f>
where Self: Sized, F: FnMut(&TSTriple<'_, Self>) -> bool + 'f,

Returns a source which uses predicate to determine if an triple should be yielded.

Source

fn filter_map_triples<'f, F, T>( self, filter_map: F, ) -> FilterMapSource<Self, impl FnMut(Self::Item<'_>) -> Option<T> + 'f>
where Self: Sized, F: FnMut(TSTriple<'_, Self>) -> Option<T> + 'f,

Returns a source that both filters and maps.

See also TripleSource::filter_triples and TripleSource::map_triples.

Source

fn map_triples<'m, F, T>( self, map: F, ) -> MapSource<Self, impl FnMut(Self::Item<'_>) -> T + 'm>
where Self: Sized, F: FnMut(TSTriple<'_, Self>) -> T + 'm,

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::MapSource recognized as a TripleSource.

As a rule of thumb, whenever map returns something satisfying the 'static lifetime, things should work as expected.

Source

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.

Source

fn to_quads(self) -> ToQuads<Self>
where Self: Sized,

Convert of triples in this source to quads (belonging to the default graph).

Source

fn collect_triples<G>(self) -> StreamResult<G, Self::Error, <G as Graph>::Error>
where Self: Sized, G: CollectibleGraph,

Collect these triples into a new graph.

Source

fn add_to_graph<G: MutableGraph>( self, graph: &mut G, ) -> StreamResult<usize, Self::Error, <G as MutableGraph>::MutationError>
where Self: Sized,

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.

Implementors§

Source§

impl<T> TripleSource for T
where T: Source + IsTripleSource,

Ensures that TripleSource acts as an type alias for any Source satisfying the conditions.