pub trait QuadSource {
    type Quad<'x>: Quad;
    type Error: Error + 'static;

    // Required method
    fn try_for_some_quad<E, F>(
        &mut self,
        f: F
    ) -> StreamResult<bool, Self::Error, E>
       where E: Error,
             F: FnMut(Self::Quad<'_>) -> Result<(), E>;

    // Provided methods
    fn try_for_each_quad<F, E>(
        &mut self,
        f: F
    ) -> StreamResult<(), Self::Error, E>
       where F: FnMut(Self::Quad<'_>) -> Result<(), E>,
             E: Error { ... }
    fn for_some_quad<F>(&mut self, f: &mut F) -> Result<bool, Self::Error>
       where F: FnMut(Self::Quad<'_>) { ... }
    fn for_each_quad<F>(&mut self, f: F) -> Result<(), Self::Error>
       where F: FnMut(Self::Quad<'_>) { ... }
    fn filter_quads<F>(self, predicate: F) -> FilterQuadSource<Self, F>
       where Self: Sized,
             F: FnMut(&Self::Quad<'_>) -> bool { ... }
    fn filter_map_quads<F, T>(
        self,
        filter_map: F
    ) -> FilterMapQuadSource<Self, F>
       where Self: Sized,
             F: FnMut(Self::Quad<'_>) -> Option<T> { ... }
    fn map_quads<F, T>(self, map: F) -> MapQuadSource<Self, F>
       where Self: Sized,
             F: FnMut(Self::Quad<'_>) -> T { ... }
    fn to_triples(self) -> ToTriples<Self>
       where Self: Sized { ... }
    fn size_hint_quads(&self) -> (usize, Option<usize>) { ... }
    fn collect_quads<D>(
        self
    ) -> StreamResult<D, Self::Error, <D as Dataset>::Error>
       where Self: Sized,
             for<'x> Self::Quad<'x>: Quad,
             D: CollectibleDataset { ... }
    fn add_to_dataset<D: MutableDataset>(
        self,
        dataset: &mut D
    ) -> StreamResult<usize, Self::Error, <D as MutableDataset>::MutationError>
       where Self: Sized,
             for<'x> Self::Quad<'x>: Quad { ... }
}
Expand description

A quad source produces quads, and may also fail in the process.

see module documentation for the rationale of his trait.

Common implementors

Any iterator yielding results of Quad implements the QuadSource trait.

Any iterator of Quad can also be converted to an Infallible QuadSource thanks to the IntoQuadSource extension trait.

Required Associated Types§

source

type Quad<'x>: Quad

The type of quads this source yields.

source

type Error: Error + 'static

The type of errors produced by this source.

Required Methods§

source

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

Call f for some quad(s) (possibly zero) from this source, if any.

Return Ok(false) if there are no more quads in this source.

Return an error if either the source or f errs.

Provided Methods§

source

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

Call f for all quads from this source.

Return an error if either the source or f errs.

source

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

Call f for some quad(s) (possibly zero) from this source, if any.

Return false if there are no more quads in this source.

Return an error if either the source errs.

source

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

Call f for all quads from this source.

Return an error if either the source errs.

source

fn filter_quads<F>(self, predicate: F) -> FilterQuadSource<Self, F>
where Self: Sized, F: FnMut(&Self::Quad<'_>) -> bool,

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

source

fn filter_map_quads<F, T>(self, filter_map: F) -> FilterMapQuadSource<Self, F>
where Self: Sized, F: FnMut(Self::Quad<'_>) -> Option<T>,

Returns a source that both filters and maps.

See also QuadSource::filter_quads and QuadSource::map_quads.

source

fn map_quads<F, T>(self, map: F) -> MapQuadSource<Self, F>
where Self: Sized, F: FnMut(Self::Quad<'_>) -> T,

Returns a source which yield the result of map for each quad.

See also QuadSource::to_triples.

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 |q| q or |q| q.to_spog() currently do not compile on all implementations of QuadSource. Furthermore, some functions returning a Quad are accepted, but fail to make the resulting map::MapQuadSource recognized as a QuadSource.

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

source

fn to_triples(self) -> ToTriples<Self>
where Self: Sized,

Convert of quads in this source to triples (stripping the graph name).

source

fn size_hint_quads(&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_quads<D>(self) -> StreamResult<D, Self::Error, <D as Dataset>::Error>
where Self: Sized, for<'x> Self::Quad<'x>: Quad, D: CollectibleDataset,

Collect these quads into a new dataset.

source

fn add_to_dataset<D: MutableDataset>( self, dataset: &mut D ) -> StreamResult<usize, Self::Error, <D as MutableDataset>::MutationError>
where Self: Sized, for<'x> Self::Quad<'x>: Quad,

Insert all quads from this source into the given MutableDataset.

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

Object Safety§

This trait is not object safe.

Implementors§

source§

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

§

type Quad<'x> = T

§

type Error = E

source§

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

§

type Quad<'x> = T

§

type Error = <S as QuadSource>::Error

source§

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

§

type Quad<'x> = T

§

type Error = <S as TripleSource>::Error

source§

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

§

type Quad<'x> = T

§

type Error = <S as QuadSource>::Error

source§

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

§

type Quad<'x> = T

§

type Error = <S as TripleSource>::Error

source§

impl<S, P> QuadSource for FilterQuadSource<S, P>
where S: QuadSource, P: FnMut(&S::Quad<'_>) -> bool,

§

type Quad<'x> = <S as QuadSource>::Quad<'x>

§

type Error = <S as QuadSource>::Error

source§

impl<TS: TripleSource> QuadSource for ToQuads<TS>

§

type Quad<'x> = ([<<TS as TripleSource>::Triple<'x> as Triple>::Term; 3], Option<<<TS as TripleSource>::Triple<'x> as Triple>::Term>)

§

type Error = <TS as TripleSource>::Error