[−][src]Struct rio_turtle::GTriGParser
A TriG streaming parser parsing generalized quads.
It implements the GeneralizedQuadsParser
trait.
Using it requires to enable the generalized
feature.
Count the number of people using the QuadsParser
API:
use rio_turtle::{GTriGParser, TurtleError}; use rio_api::parser::GeneralizedQuadsParser; use rio_api::model::NamedNode; let file = b"@prefix schema: <http://schema.org/> . <http://example/> { <http://example.com/foo> a schema:Person ; schema:name ?name . <http://example.com/bar> a schema:Person ; schema:name ?name . }"; let rdf_type = NamedNode { iri: "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" }; let schema_person = NamedNode { iri: "http://schema.org/Person" }; let mut count = 0; GTriGParser::new(file.as_ref(), None).parse_all(&mut |t| { if t.predicate == rdf_type.into() && t.object == schema_person.into() { count += 1; } Ok(()) as Result<(), TurtleError> })?; assert_eq!(2, count);
Implementations
impl<R: BufRead> GTriGParser<R>
[src]
pub fn new(reader: R, base_iri: Option<Iri<String>>) -> Self
[src]
Builds the parser from a BufRead
implementation, and a base IRI for relative IRI resolution.
Trait Implementations
impl<R: BufRead> GeneralizedQuadsParser for GTriGParser<R>
[src]
type Error = TurtleError
fn parse_step<E: From<TurtleError>>(
&mut self,
on_quad: &mut impl FnMut(GeneralizedQuad) -> Result<(), E>
) -> Result<(), E>
[src]
&mut self,
on_quad: &mut impl FnMut(GeneralizedQuad) -> Result<(), E>
) -> Result<(), E>
fn is_end(&self) -> bool
[src]
fn parse_all<E>(
&mut self,
on_quad: &mut impl FnMut(GeneralizedQuad) -> Result<(), E>
) -> Result<(), E> where
E: From<Self::Error>,
[src]
&mut self,
on_quad: &mut impl FnMut(GeneralizedQuad) -> Result<(), E>
) -> Result<(), E> where
E: From<Self::Error>,
fn into_iter<T, E, F>(
self,
convert_quad: F
) -> GeneralizedQuadsParserIterator<T, E, F, Self> where
E: From<Self::Error>,
F: FnMut(GeneralizedQuad) -> Result<T, E>,
[src]
self,
convert_quad: F
) -> GeneralizedQuadsParserIterator<T, E, F, Self> where
E: From<Self::Error>,
F: FnMut(GeneralizedQuad) -> Result<T, E>,
impl<B: BufRead> QuadSource for GTriGParser<B>
[src]
type Error = <GTriGParser<B> as GeneralizedQuadsParser>::Error
The type of errors produced by this source.
type Quad = ScopedGeneralizedQuad
Determine the type of Quad
s that this quad source yields. (see streaming_mode
Read more
fn try_for_some_quad<F, EF>(
&mut self,
f: &mut F
) -> StreamResult<bool, Self::Error, EF> where
F: FnMut(StreamedQuad<Self::Quad>) -> Result<(), EF>,
EF: Error,
[src]
&mut self,
f: &mut F
) -> StreamResult<bool, Self::Error, EF> where
F: FnMut(StreamedQuad<Self::Quad>) -> Result<(), EF>,
EF: Error,
fn try_for_each_quad<F, E>(
&mut self,
f: F
) -> Result<(), StreamError<Self::Error, E>> where
E: Error,
F: FnMut(StreamedQuad<Self::Quad>) -> Result<(), E>,
[src]
&mut self,
f: F
) -> Result<(), StreamError<Self::Error, E>> where
E: Error,
F: FnMut(StreamedQuad<Self::Quad>) -> Result<(), E>,
fn for_some_quad<F>(&mut self, f: &mut F) -> Result<bool, Self::Error> where
F: FnMut(StreamedQuad<Self::Quad>),
[src]
F: FnMut(StreamedQuad<Self::Quad>),
fn for_each_quad<F>(&mut self, f: F) -> Result<(), Self::Error> where
F: FnMut(StreamedQuad<Self::Quad>),
[src]
F: FnMut(StreamedQuad<Self::Quad>),
fn filter_quads<F>(self, filter: F) -> FilterSource<Self, F> where
F: FnMut(&StreamedQuad<Self::Quad>) -> bool,
[src]
F: FnMut(&StreamedQuad<Self::Quad>) -> bool,
fn filter_map_quads<F, T>(self, filter_map: F) -> FilterMapSource<Self, F> where
F: FnMut(StreamedQuad<Self::Quad>) -> Option<T>,
[src]
F: FnMut(StreamedQuad<Self::Quad>) -> Option<T>,
fn map_quads<F, T>(self, map: F) -> MapSource<Self, F> where
F: FnMut(StreamedQuad<Self::Quad>) -> T,
[src]
F: FnMut(StreamedQuad<Self::Quad>) -> T,
fn size_hint_quads(&self) -> (usize, Option<usize>)
[src]
fn collect_quads<D>(
self
) -> Result<D, StreamError<Self::Error, <D as Dataset>::Error>> where
D: CollectibleDataset,
[src]
self
) -> Result<D, StreamError<Self::Error, <D as Dataset>::Error>> where
D: CollectibleDataset,
fn add_to_dataset<D>(
self,
dataset: &mut D
) -> Result<usize, StreamError<Self::Error, <D as MutableDataset>::MutationError>> where
D: MutableDataset,
[src]
self,
dataset: &mut D
) -> Result<usize, StreamError<Self::Error, <D as MutableDataset>::MutationError>> where
D: MutableDataset,
Auto Trait Implementations
impl<R> RefUnwindSafe for GTriGParser<R> where
R: RefUnwindSafe,
R: RefUnwindSafe,
impl<R> Send for GTriGParser<R> where
R: Send,
R: Send,
impl<R> Sync for GTriGParser<R> where
R: Sync,
R: Sync,
impl<R> Unpin for GTriGParser<R> where
R: Unpin,
R: Unpin,
impl<R> UnwindSafe for GTriGParser<R> where
R: UnwindSafe,
R: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I, T, E> QuadSource for I where
E: 'static + Error,
I: Iterator<Item = Result<T, E>>,
T: Quad,
[src]
E: 'static + Error,
I: Iterator<Item = Result<T, E>>,
T: Quad,
type Error = E
The type of errors produced by this source.
type Quad = ByValue<T>
Determine the type of Quad
s that this quad source yields. (see streaming_mode
Read more
fn try_for_some_quad<F, EF>(
&mut self,
f: &mut F
) -> Result<bool, StreamError<E, EF>> where
EF: Error,
F: FnMut(StreamedQuad<<I as QuadSource>::Quad>) -> Result<(), EF>,
[src]
&mut self,
f: &mut F
) -> Result<bool, StreamError<E, EF>> where
EF: Error,
F: FnMut(StreamedQuad<<I as QuadSource>::Quad>) -> Result<(), EF>,
fn try_for_each_quad<F, E>(
&mut self,
f: F
) -> Result<(), StreamError<Self::Error, E>> where
E: Error,
F: FnMut(StreamedQuad<Self::Quad>) -> Result<(), E>,
[src]
&mut self,
f: F
) -> Result<(), StreamError<Self::Error, E>> where
E: Error,
F: FnMut(StreamedQuad<Self::Quad>) -> Result<(), E>,
fn for_some_quad<F>(&mut self, f: &mut F) -> Result<bool, Self::Error> where
F: FnMut(StreamedQuad<Self::Quad>),
[src]
F: FnMut(StreamedQuad<Self::Quad>),
fn for_each_quad<F>(&mut self, f: F) -> Result<(), Self::Error> where
F: FnMut(StreamedQuad<Self::Quad>),
[src]
F: FnMut(StreamedQuad<Self::Quad>),
fn filter_quads<F>(self, filter: F) -> FilterSource<Self, F> where
F: FnMut(&StreamedQuad<Self::Quad>) -> bool,
[src]
F: FnMut(&StreamedQuad<Self::Quad>) -> bool,
fn filter_map_quads<F, T>(self, filter_map: F) -> FilterMapSource<Self, F> where
F: FnMut(StreamedQuad<Self::Quad>) -> Option<T>,
[src]
F: FnMut(StreamedQuad<Self::Quad>) -> Option<T>,
fn map_quads<F, T>(self, map: F) -> MapSource<Self, F> where
F: FnMut(StreamedQuad<Self::Quad>) -> T,
[src]
F: FnMut(StreamedQuad<Self::Quad>) -> T,
fn size_hint_quads(&self) -> (usize, Option<usize>)
[src]
fn collect_quads<D>(
self
) -> Result<D, StreamError<Self::Error, <D as Dataset>::Error>> where
D: CollectibleDataset,
[src]
self
) -> Result<D, StreamError<Self::Error, <D as Dataset>::Error>> where
D: CollectibleDataset,
fn add_to_dataset<D>(
self,
dataset: &mut D
) -> Result<usize, StreamError<Self::Error, <D as MutableDataset>::MutationError>> where
D: MutableDataset,
[src]
self,
dataset: &mut D
) -> Result<usize, StreamError<Self::Error, <D as MutableDataset>::MutationError>> where
D: MutableDataset,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,