Expand description
Utilities to read and write RDF graphs and datasets using OxRDF I/O.
The entry points of this module are the two RdfParser
and RdfSerializer
structs.
Usage example converting a Turtle file to a N-Triples file:
use oxigraph::io::{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);
Re-exports§
pub use self::read::DatasetParser;
Deprecated pub use self::read::GraphParser;
Deprecated pub use self::write::DatasetSerializer;
Deprecated pub use self::write::GraphSerializer;
Deprecated
Modules§
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
Read
implementation. - Slice
Quad Parser - Parses a RDF file from a byte slice.
- Text
Position - A position in a text i.e. a
line
number starting from 0, acolumn
number starting from 0 (in number of code points) and a global fileoffset
starting from 0 (in number of bytes). - Writer
Quad Serializer - Serializes quads or triples to a
Write
implementation.
Enums§
- Dataset
Format Deprecated - RDF dataset serialization formats.
- Graph
Format Deprecated - RDF graph serialization formats.
- Json
LdProfile - JSON-Ld profile.
- RdfFormat
- RDF serialization formats.
- RdfParse
Error - Error returned during RDF format parsing.