[][src]Struct rio_turtle::GTriGParser

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

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

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 Quads that this quad source yields. (see streaming_mode Read more

Auto Trait Implementations

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

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

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

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

impl<R> UnwindSafe for GTriGParser<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<I, T, E> QuadSource for I where
    E: 'static + Error,
    I: Iterator<Item = Result<T, E>>,
    T: Quad
[src]

type Error = E

The type of errors produced by this source.

type Quad = ByValue<T>

Determine the type of Quads that this quad source yields. (see streaming_mode Read more

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.