#rdf #n-triples #turtle #n-quads #n3 #tri-g

oxttl

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

17 releases

0.1.7 Mar 9, 2025
0.1.5 Jan 11, 2025
0.1.4 Dec 21, 2024
0.1.3 Nov 7, 2024
0.1.0-alpha.5 Mar 25, 2024

#629 in Database interfaces

Download history 347/week @ 2024-12-15 193/week @ 2024-12-22 384/week @ 2024-12-29 397/week @ 2025-01-05 406/week @ 2025-01-12 438/week @ 2025-01-19 175/week @ 2025-01-26 319/week @ 2025-02-02 470/week @ 2025-02-09 542/week @ 2025-02-16 468/week @ 2025-02-23 430/week @ 2025-03-02 699/week @ 2025-03-09 468/week @ 2025-03-16 539/week @ 2025-03-23 483/week @ 2025-03-30

2,240 downloads per month
Used in 41 crates (6 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