Expand description
§OxRDF I/O
OxRDF I/O is a set of parsers and serializers for RDF.
It supports:
- JSON-LD 1.0 using
oxjsonld - N3 using
oxttl - N-Quads using
oxttl - N-Triples using
oxttl - RDF/XML using
oxrdfxml - TriG using
oxttl - Turtle using
oxttl
Support for RDF 1.2 is available behind the rdf-12 feature.
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 serializer = RdfSerializer::from_format(RdfFormat::NTriples).for_writer(Vec::new());
for quad in RdfParser::from_format(RdfFormat::Turtle).for_reader(turtle_file.as_ref()) {
serializer.serialize_quad(&quad.unwrap()).unwrap();
}
assert_eq!(serializer.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.
Structs§
- Json
LdProfile Set - Set of JSON-Ld profiles.
- Loaded
Document - A remote document fetched to support parsing.
- RdfParser
- Parsers for RDF serialization formats.
- RdfSerializer
- A serializer for RDF serialization formats.
- RdfSyntax
Error - An error in the syntax of the parsed file.
- Reader
Quad Parser - Parses a RDF file from a
Readimplementation. - Slice
Quad Parser - Parses a RDF file from a byte slice.
- Text
Position - A position in a text i.e. a
linenumber starting from 0, acolumnnumber starting from 0 (in number of code points) and a global fileoffsetstarting from 0 (in number of bytes). - Tokio
Async Reader Quad Parser async-tokio - Parses an RDF file from a Tokio
AsyncReadimplementation. - Tokio
Async Writer Quad Serializer async-tokio - Serializes quads or triples to a
AsyncWriteimplementation. - Writer
Quad Serializer - Serializes quads or triples to a
Writeimplementation.
Enums§
- Json
LdProfile - JSON-Ld profile.
- RdfFormat
- RDF serialization formats.
- RdfParse
Error - Error returned during RDF format parsing.