Struct rdf_rs::parsing::TurtleParser[][src]

pub struct TurtleParser;

Trait Implementations

Parses a Uri from a string

Errors

Returns a ParserError if the string is not a valid URI

Examples

let uri = TurtleParser::uri("<http://example.com/rdf/Person>")?;
let uri = TurtleParser::uri("<#Person>")?;
let uri = TurtleParser::uri("ex:Person")?;
let uri = TurtleParser::uri(":Person")?;

Parses a Resource from a string. A wrapper around RDFParser::uri() specifically for RDF resources.

Errors

Returns a ParserError if the string is not a valid Resource

Examples

let res = TurtleParser::resource("<http://example.com/rdf/Person>")?;
let res = TurtleParser::resource("<#Person>")?;
let res = TurtleParser::resource("ex:Person")?;
let res = TurtleParser::resource(":Person")?;

Parses a Relationship from a string. A wrapper around RDFParser::uri() specifically for RDF relationships.

Errors

Returns a ParserError if the string is not a valid Relationship

Examples

let rel = TurtleParser::relationship("<http://example.com/foaf#knows>")?;
let rel = TurtleParser::relationship("<#knows>")?;
let rel = TurtleParser::relationship("foaf:knows")?;
let rel = TurtleParser::relationship(":knows")?;

Parses an Object from a string.

Errors

Returns a ParserError if the string is not a valid Object

Examples

let obj = TurtleParser::object(r#""john@example.com""#)?;
let obj = TurtleParser::object(r#""すし"@jp"#)?;
let obj = TurtleParser::object("foaf:Person")?;

Parses a Vec<Triple> from a string.

Errors

Returns a ParserError if the string is not a valid Triple or collection of triples.

Examples

let triple = TurtleParser::triple(r#"ex:John foaf:mbox "john@example.com" ."#)?;
let triple = TurtleParser::triple(r#"[ foaf:name "Alice" ] foaf:knows [ foaf:name "Bob" ] ."#)?;

Parses a Graph from a string (typically a file).

Errors

Returns a ParserError if the string is not a valid Graph.

Examples

let triple = TurtleParser::graph(r#"
    @base <http://example.com/> .
    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    @prefix owl: <http://www.w3.org/2002/07/owl#> .

    :John foaf:mbox "john@example.com" .
    [ foaf:mbox "john@example.com" ] owl:sameAs :John .
"#)?;

Acts as a wrapper around RDFParser::graph() that automatically reads and parses a file. 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.