Struct rio_turtle::TriGParser
source · [−]pub struct TriGParser<R: BufRead> { /* private fields */ }
Expand description
A TriG and TriG-star streaming parser.
It implements the QuadsParser
trait.
Count the number of people using the QuadsParser
API:
use rio_turtle::{TriGParser, TurtleError};
use rio_api::parser::QuadsParser;
use rio_api::model::NamedNode;
let file = b"@prefix schema: <http://schema.org/> .
<http://example/> {
<http://example.com/foo> a schema:Person ;
schema:name \"Foo\" .
<http://example.com/bar> a schema:Person ;
schema: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;
TriGParser::new(file.as_ref(), None).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
sourceimpl<R: BufRead> TriGParser<R>
impl<R: BufRead> TriGParser<R>
Trait Implementations
sourceimpl<R: BufRead> QuadsParser for TriGParser<R>
impl<R: BufRead> QuadsParser for TriGParser<R>
type Error = TurtleError
sourcefn parse_step<E: From<TurtleError>>(
&mut self,
on_quad: &mut impl FnMut(Quad<'_>) -> Result<(), E>
) -> Result<(), E>
fn parse_step<E: From<TurtleError>>(
&mut self,
on_quad: &mut impl FnMut(Quad<'_>) -> Result<(), E>
) -> Result<(), E>
Parses a small chunk of the file and calls on_quad
each time a new quad is read.
(A “small chunk” could be a line for an N-Quads parser.) Read more
Auto Trait Implementations
impl<R> RefUnwindSafe for TriGParser<R> where
R: RefUnwindSafe,
impl<R> Send for TriGParser<R> where
R: Send,
impl<R> Sync for TriGParser<R> where
R: Sync,
impl<R> Unpin for TriGParser<R> where
R: Unpin,
impl<R> UnwindSafe for TriGParser<R> where
R: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more