#parser-serializer #turtle #n-triples #n-quads #async-io #n3 #tri-g

oxttl

Parser and serializer for languages related to RDF Turtle (N-Triples, N-Quads, Turtle, TriG and N3)

5 releases

0.1.0-alpha.5 Mar 25, 2024
0.1.0-alpha.4 Mar 23, 2024
0.1.0-alpha.3 Mar 7, 2024
0.1.0-alpha.2 Jan 25, 2024
0.1.0-alpha.1 Jan 3, 2024

#689 in Database interfaces

Download history 20/week @ 2024-01-22 80/week @ 2024-01-29 53/week @ 2024-02-05 8/week @ 2024-02-12 75/week @ 2024-02-19 72/week @ 2024-02-26 186/week @ 2024-03-04 46/week @ 2024-03-11 165/week @ 2024-03-18 186/week @ 2024-03-25 78/week @ 2024-04-01 33/week @ 2024-04-08 37/week @ 2024-04-15 32/week @ 2024-04-22 20/week @ 2024-04-29 13/week @ 2024-05-06

106 downloads per month
Used in 12 crates (4 directly)

MIT/Apache

505KB
10K SLoC

OxTTL

Latest Version Released API docs Crates.io downloads actions status Gitter

Oxttl is a set of parsers and serializers for Turtle, TriG, N-Triples, N-Quads and N3.

Support for SPARQL-star is also available behind the rdf-starfeature for all languages but N3 (Turtle-star, TriG-star, N-Triples-star and N-Quads-star)

It is designed as a low level parser compatible with both synchronous and asynchronous I/O.

Usage example counting the number of people in a Turtle file:

use oxrdf::{NamedNodeRef, vocab::rdf};
use oxttl::TurtleParser;

let file = b"@base <http://example.com/> .
@prefix schema: <http://schema.org/> .
<foo> a schema:Person ;
    schema:name \"Foo\" .
<bar> a schema:Person ;
    schema:name \"Bar\" .";

let schema_person = NamedNodeRef::new("http://schema.org/Person").unwrap();
let mut count = 0;
for triple in TurtleParser::new().parse_read(file.as_ref()) {
    let triple = triple.unwrap();
    if triple.predicate == rdf::TYPE && triple.object == schema_person.into() {
        count += 1;
    }
}
assert_eq!(2, count);

License

This project is licensed under either of

  • Apache License, Version 2.0, (LICENSE-APACHE or <http://www.apache.org/licenses/LICENSE-2.0>)
  • MIT license (LICENSE-MIT or <http://opensource.org/licenses/MIT>)

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Oxigraph by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0.8–2.6MB
~49K SLoC