QuadSource

Trait QuadSource 

Source
pub trait QuadSource: Source + IsQuadSource {
    // Provided methods
    fn try_for_some_quad<E, F>(
        &mut self,
        f: F,
    ) -> StreamResult<bool, Self::Error, E>
       where E: Error + Send + Sync + 'static,
             F: FnMut(Self::Quad<'_>) -> Result<(), E> { ... }
    fn try_for_each_quad<F, E>(
        &mut self,
        f: F,
    ) -> StreamResult<(), Self::Error, E>
       where F: FnMut(Self::Quad<'_>) -> Result<(), E>,
             E: Error + Send + Sync + 'static { ... }
    fn for_some_quad<F>(&mut self, f: 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, F>(
        self,
        predicate: F,
    ) -> FilterQuadSource<Self, impl FnMut(&Self::Item<'_>) -> bool + 'f>
       where Self: Sized,
             F: FnMut(&QSQuad<'_, Self>) -> bool + 'f { ... }
    fn filter_map_quads<'f, F, T>(
        self,
        filter_map: F,
    ) -> FilterMapSource<Self, impl FnMut(Self::Item<'_>) -> Option<T> + 'f>
       where Self: Sized,
             F: FnMut(Self::Quad<'_>) -> Option<T> + 'f { ... }
    fn map_quads<'f, F, T>(
        self,
        map: F,
    ) -> MapSource<Self, impl FnMut(Self::Item<'_>) -> T + 'f>
       where Self: Sized,
             F: FnMut(Self::Quad<'_>) -> T + 'f { ... }
    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 is a Source producing quads.

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

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

See also QSQuad.

Provided Methods§

Source

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

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 + Send + Sync + 'static,

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: 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, F>( self, predicate: F, ) -> FilterQuadSource<Self, impl FnMut(&Self::Item<'_>) -> bool + 'f>
where Self: Sized, F: FnMut(&QSQuad<'_, Self>) -> bool + 'f,

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

Source

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

Returns a source that both filters and maps.

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

Source

fn map_quads<'f, F, T>( self, map: F, ) -> MapSource<Self, impl FnMut(Self::Item<'_>) -> T + 'f>
where Self: Sized, F: FnMut(Self::Quad<'_>) -> T + 'f,

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::MapSource 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).

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> QuadSource for T
where T: Source + IsQuadSource,

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