#parser-serializer #turtle #n-triples #serialization #n-quads #tri-g #n3

oxttl

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

13 releases

0.1.3 Nov 7, 2024
0.1.2 Oct 31, 2024
0.1.0 Sep 22, 2024
0.1.0-rc.1 Aug 25, 2024
0.1.0-alpha.2 Jan 25, 2024

#526 in Database interfaces

Download history 219/week @ 2024-07-30 1182/week @ 2024-08-06 304/week @ 2024-08-13 564/week @ 2024-08-20 418/week @ 2024-08-27 431/week @ 2024-09-03 494/week @ 2024-09-10 911/week @ 2024-09-17 434/week @ 2024-09-24 538/week @ 2024-10-01 574/week @ 2024-10-08 328/week @ 2024-10-15 686/week @ 2024-10-22 717/week @ 2024-10-29 350/week @ 2024-11-05 459/week @ 2024-11-12

2,291 downloads per month
Used in 27 crates (4 directly)

MIT/Apache

555KB
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().for_reader(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.7–7MB
~46K SLoC