Struct rio_turtle::TurtleParser[][src]

pub struct TurtleParser<R: BufRead> { /* fields omitted */ }

A Turtle streaming parser.

It implements the TriplesParser trait.

Count the number of people using the TriplesParser API:

use rio_turtle::{TurtleParser, TurtleError};
use rio_api::parser::TriplesParser;
use rio_api::model::NamedNode;

let file = b"@prefix schema: <http://schema.org/> .
<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;
TurtleParser::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

impl<R: BufRead> TurtleParser<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<B: BufRead> TripleSource for TurtleParser<B>[src]

type Error = <TurtleParser<B> as TriplesParser>::Error

The type of errors produced by this source.

type Triple = ScopedRioSourceTriple

Determine the type of Triples that this triple source yields. (see streaming_mode Read more

impl<R: BufRead> TriplesParser for TurtleParser<R>[src]

type Error = TurtleError

Auto Trait Implementations

impl<R> RefUnwindSafe for TurtleParser<R> where
    R: RefUnwindSafe

impl<R> Send for TurtleParser<R> where
    R: Send

impl<R> Sync for TurtleParser<R> where
    R: Sync

impl<R> Unpin for TurtleParser<R> where
    R: Unpin

impl<R> UnwindSafe for TurtleParser<R> where
    R: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.