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§

source

type Triple<'x>: Triple

The type of triples this source yields.

source

type Error: Error + 'static

The type of errors produced by this source.

Required Methods§

source

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>,

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§

source

fn try_for_each_triple<F, E>( &mut self, f: F ) -> StreamResult<(), Self::Error, E>
where F: FnMut(Self::Triple<'_>) -> Result<(), E>, E: Error,

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: &mut F) -> Result<bool, Self::Error>
where F: FnMut(Self::Triple<'_>),

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(Self::Triple<'_>),

Call f for all triples from this source.

Return an error if either the source errs.

source

fn filter_triples<F>(self, predicate: F) -> FilterTripleSource<Self, F>
where Self: Sized, F: FnMut(&Self::Triple<'_>) -> bool,

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

source

fn filter_map_triples<F, T>( self, filter_map: F ) -> FilterMapTripleSource<Self, F>
where Self: Sized, F: FnMut(Self::Triple<'_>) -> Option<T>,

Returns a source that both filters and maps.

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

source

fn map_triples<F, T>(self, map: F) -> MapTripleSource<Self, F>
where Self: Sized, F: FnMut(Self::Triple<'_>) -> T,

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.

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 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 collect_triples<G>(self) -> StreamResult<G, Self::Error, <G as Graph>::Error>
where Self: Sized, for<'x> Self::Triple<'x>: Triple, 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, for<'x> Self::Triple<'x>: Triple,

Insert all triples from this source into the given MutableGraph.

Stop on the first error (in the source or in the graph).

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'a, I, T, E> TripleSource for I
where I: Iterator<Item = Result<T, E>> + 'a, T: Triple, E: Error + 'static,

§

type Triple<'x> = T

§

type Error = E

source§

impl<QS: QuadSource> TripleSource for ToTriples<QS>

§

type Triple<'x> = [<<QS as QuadSource>::Quad<'x> as Quad>::Term; 3]

§

type Error = <QS as QuadSource>::Error

source§

impl<S, F, T> TripleSource for FilterMapQuadSource<S, F>
where S: QuadSource, F: FnMut(S::Quad<'_>) -> Option<T>, T: Triple,

§

type Triple<'x> = T

§

type Error = <S as QuadSource>::Error

source§

impl<S, F, T> TripleSource for FilterMapTripleSource<S, F>
where S: TripleSource, F: FnMut(S::Triple<'_>) -> Option<T>, T: Triple,

§

type Triple<'x> = T

§

type Error = <S as TripleSource>::Error

source§

impl<S, F, T> TripleSource for MapQuadSource<S, F>
where S: QuadSource, F: FnMut(S::Quad<'_>) -> T, T: Triple,

§

type Triple<'x> = T

§

type Error = <S as QuadSource>::Error

source§

impl<S, F, T> TripleSource for MapTripleSource<S, F>
where S: TripleSource, F: FnMut(S::Triple<'_>) -> T, T: Triple,

§

type Triple<'x> = T

§

type Error = <S as TripleSource>::Error

source§

impl<S, P> TripleSource for FilterTripleSource<S, P>
where S: TripleSource, P: FnMut(&S::Triple<'_>) -> bool,

§

type Triple<'x> = <S as TripleSource>::Triple<'x>

§

type Error = <S as TripleSource>::Error