Struct rio_turtle::NQuadsParser [−][src]
A N-Quads streaming parser.
It implements the QuadsParser
trait.
Its memory consumption is linear in the size of the longest line of the file. It does not do any allocation during parsing except buffer resizing if a line significantly longer than the previous is encountered.
Count the number of people using the QuadsParser
API:
use rio_turtle::{NQuadsParser, TurtleError}; use rio_api::parser::QuadsParser; use rio_api::model::NamedNode; let file = b"<http://example.com/foo> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> <http://example.com/> . <http://example.com/foo> <http://schema.org/name> \"Foo\" <http://example.com/> . <http://example.com/bar> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> . <http://example.com/bar> <http://schema.org/name> \"Bar\" ."; 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; NQuadsParser::new(file.as_ref()).parse_all(&mut |t| { if t.predicate == rdf_type && t.object == schema_person.into() { count += 1; } Ok(()) as Result<(), TurtleError> })?; assert_eq!(2, count);
Implementations
impl<R: BufRead> NQuadsParser<R>
[src]
Trait Implementations
impl<B: BufRead> QuadSource for NQuadsParser<B>
[src]
type Error = <NQuadsParser<B> as QuadsParser>::Error
The type of errors produced by this source.
type Quad = ScopedRioSourceQuad
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,
pub 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>,
pub 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>),
pub fn for_each_quad<F>(&mut self, f: F) -> Result<(), Self::Error> where
F: FnMut(StreamedQuad<'_, Self::Quad>),
[src]
F: FnMut(StreamedQuad<'_, Self::Quad>),
pub fn filter_quads<F>(self, filter: F) -> FilterSource<Self, F> where
F: FnMut(&StreamedQuad<'_, Self::Quad>) -> bool,
[src]
F: FnMut(&StreamedQuad<'_, Self::Quad>) -> bool,
pub 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>,
pub 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,
pub fn size_hint_quads(&self) -> (usize, Option<usize>)
[src]
pub 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,
pub 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<R: BufRead> QuadsParser for NQuadsParser<R>
[src]
type Error = TurtleError
fn parse_step<E: From<TurtleError>>(
&mut self,
on_quad: &mut impl FnMut(Quad<'_>) -> Result<(), E>
) -> Result<(), E>
[src]
&mut self,
on_quad: &mut impl FnMut(Quad<'_>) -> Result<(), E>
) -> Result<(), E>
fn is_end(&self) -> bool
[src]
pub fn parse_all<E>(
&mut self,
on_quad: &mut impl FnMut(Quad<'_>) -> Result<(), E>
) -> Result<(), E> where
E: From<Self::Error>,
[src]
&mut self,
on_quad: &mut impl FnMut(Quad<'_>) -> Result<(), E>
) -> Result<(), E> where
E: From<Self::Error>,
pub fn into_iter<T, E, F>(
self,
convert_quad: F
) -> QuadsParserIterator<T, E, F, Self> where
E: From<Self::Error>,
F: FnMut(Quad<'_>) -> Result<T, E>,
[src]
self,
convert_quad: F
) -> QuadsParserIterator<T, E, F, Self> where
E: From<Self::Error>,
F: FnMut(Quad<'_>) -> Result<T, E>,
Auto Trait Implementations
impl<R> RefUnwindSafe for NQuadsParser<R> where
R: RefUnwindSafe,
R: RefUnwindSafe,
impl<R> Send for NQuadsParser<R> where
R: Send,
R: Send,
impl<R> Sync for NQuadsParser<R> where
R: Sync,
R: Sync,
impl<R> Unpin for NQuadsParser<R> where
R: Unpin,
R: Unpin,
impl<R> UnwindSafe for NQuadsParser<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,
pub 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<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.
pub 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>,