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

A TriG streaming parser parsing generalized quads.

Warning: RDF-star is not supported yet.

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

Builds the parser from a BufRead implementation, and a base IRI for relative IRI resolution.

Trait Implementations

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

Returns true if the file has been completely consumed by the parser.

Parses the complete file and calls on_quad each time a new quad is read. Read more

Converts the parser into a Result<T, E> iterator. Read more

The type of errors produced by this source.

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

Call f for at least one quad from this quad source, if any. Read more

Call f for all quads from this quad source.

Call f for at least one quad from this quad source, if any. Read more

Call f for all quads from this quad source.

Creates a quad source which uses a closure to determine if a quad should be yielded.

Creates a quad source that both filters and maps.

Takes a closure and creates quad source which yield the result of that closure for each quad.

Returns the bounds on the remaining length of the quad source. Read more

Collect these quads into a new dataset.

Insert all quads from this source into the given MutableDataset. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.