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§
Required Methods§
Sourcefn try_for_some_quad<E, F>(
&mut self,
f: F,
) -> StreamResult<bool, Self::Error, E>
fn try_for_some_quad<E, F>( &mut self, f: F, ) -> StreamResult<bool, Self::Error, 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§
Sourcefn try_for_each_quad<F, E>(&mut self, f: F) -> StreamResult<(), Self::Error, E>
fn try_for_each_quad<F, E>(&mut self, f: F) -> StreamResult<(), Self::Error, E>
Call f for all quads from this source.
Return an error if either the source or f
errs.
Sourcefn for_some_quad<F>(&mut self, f: &mut F) -> Result<bool, Self::Error>
fn for_some_quad<F>(&mut self, f: &mut F) -> Result<bool, Self::Error>
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.
Sourcefn for_each_quad<F>(&mut self, f: F) -> Result<(), Self::Error>
fn for_each_quad<F>(&mut self, f: F) -> Result<(), Self::Error>
Call f for all quads from this source.
Return an error if either the source errs.
Sourcefn filter_quads<F>(self, predicate: F) -> FilterQuadSource<Self, F>
fn filter_quads<F>(self, predicate: F) -> FilterQuadSource<Self, F>
Returns a source which uses predicate
to determine if an quad should be yielded.
Sourcefn filter_map_quads<F, T>(self, filter_map: F) -> FilterMapQuadSource<Self, F>
fn filter_map_quads<F, T>(self, filter_map: F) -> FilterMapQuadSource<Self, F>
Returns a source that both filters and maps.
See also QuadSource::filter_quads
and QuadSource::map_quads
.
Sourcefn map_quads<F, T>(self, map: F) -> MapQuadSource<Self, F>
fn map_quads<F, T>(self, map: F) -> MapQuadSource<Self, 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::MapQuadSource
recognized as a QuadSource
.
As a rule of thumb,
whenever map
returns something satisfying the 'static
lifetime,
things should work as expected.
Sourcefn to_triples(self) -> ToTriples<Self>where
Self: Sized,
fn to_triples(self) -> ToTriples<Self>where
Self: Sized,
Convert of quads in this source to triples (stripping the graph name).
Sourcefn size_hint_quads(&self) -> (usize, Option<usize>)
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
.
Sourcefn collect_quads<D>(self) -> StreamResult<D, Self::Error, <D as Dataset>::Error>
fn collect_quads<D>(self) -> StreamResult<D, Self::Error, <D as Dataset>::Error>
Collect these quads into a new dataset.
Sourcefn add_to_dataset<D: MutableDataset>(
self,
dataset: &mut D,
) -> StreamResult<usize, Self::Error, <D as MutableDataset>::MutationError>
fn add_to_dataset<D: MutableDataset>( self, dataset: &mut D, ) -> StreamResult<usize, Self::Error, <D as MutableDataset>::MutationError>
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.