[−][src]Struct rio_turtle::TriGParser
A TriG streaming parser.
It implements the QuadsParser
trait.
Count the number of 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(), "").unwrap().parse_all(&mut |t| { if t.predicate == rdf_type && t.object == schema_person.into() { count += 1; } Ok(()) as Result<(), TurtleError> }).unwrap(); assert_eq!(2, count)
Methods
impl<R: BufRead> TriGParser<R>
[src]
pub fn new(reader: R, base_iri: &str) -> Result<Self, TurtleError>
[src]
Builds the parser from a BufRead
implementation and a base IRI for relative IRI resolution.
The base IRI might be empty to state there is no base URL.
Trait Implementations
impl<R: BufRead> QuadsParser for TriGParser<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]
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>,
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 TriGParser<R> where
R: RefUnwindSafe,
R: RefUnwindSafe,
impl<R> Send for TriGParser<R> where
R: Send,
R: Send,
impl<R> Sync for TriGParser<R> where
R: Sync,
R: Sync,
impl<R> Unpin for TriGParser<R> where
R: Unpin,
R: Unpin,
impl<R> UnwindSafe for TriGParser<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<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>,