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

#2092 in Parser implementations

Download history 18/week @ 2024-01-01 24/week @ 2024-01-08 79/week @ 2024-01-15 19/week @ 2024-01-22 78/week @ 2024-01-29 51/week @ 2024-02-05 7/week @ 2024-02-12 70/week @ 2024-02-19 65/week @ 2024-02-26 182/week @ 2024-03-04 119/week @ 2024-03-11 150/week @ 2024-03-18 163/week @ 2024-03-25 55/week @ 2024-04-01

496 downloads per month
Used in 9 crates (via srdf)

MIT/Apache

655KB
12K SLoC

OxRDF I/O

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

OxRDF I/O is a set of parsers and serializers for RDF.

It supports:

Support for SPARQL-star is also available behind the rdf-starfeature for 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 (behind the async-tokio feature).

The entry points of this library are the two RdfParser and RdfSerializer structs.

Usage example converting a Turtle file to a N-Triples file:

use oxrdfio::{RdfFormat, RdfParser, RdfSerializer};

let turtle_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 ntriples_file = b"<http://example.com/foo> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
<http://example.com/foo> <http://schema.org/name> \"Foo\" .
<http://example.com/bar> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
<http://example.com/bar> <http://schema.org/name> \"Bar\" .
";

let mut writer = RdfSerializer::from_format(RdfFormat::NTriples).serialize_to_write(Vec::new());
for quad in RdfParser::from_format(RdfFormat::Turtle).parse_read(turtle_file.as_ref()) {
    writer.write_quad(&quad.unwrap()).unwrap();
}
assert_eq!(writer.finish().unwrap(), ntriples_file);

Parsers for other RDF formats exists in Rust like graph-rdfa-processor for RDFa and json-ld for JSON-LD.

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

~1.8–3.5MB
~66K SLoC