oxigraph/io/
mod.rs

1//! Utilities to read and write RDF graphs and datasets using [OxRDF I/O](https://crates.io/crates/oxrdfio).
2//!
3//! The entry points of this module are the two [`RdfParser`] and [`RdfSerializer`] structs.
4//!
5//! Usage example converting a Turtle file to a N-Triples file:
6//! ```
7//! use oxigraph::io::{RdfFormat, RdfParser, RdfSerializer};
8//!
9//! let turtle_file = b"@base <http://example.com/> .
10//! @prefix schema: <http://schema.org/> .
11//! <foo> a schema:Person ;
12//!     schema:name \"Foo\" .
13//! <bar> a schema:Person ;
14//!     schema:name \"Bar\" .";
15//!
16//! let ntriples_file = b"<http://example.com/foo> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
17//! <http://example.com/foo> <http://schema.org/name> \"Foo\" .
18//! <http://example.com/bar> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
19//! <http://example.com/bar> <http://schema.org/name> \"Bar\" .
20//! ";
21//!
22//! let mut serializer = RdfSerializer::from_format(RdfFormat::NTriples).for_writer(Vec::new());
23//! for quad in RdfParser::from_format(RdfFormat::Turtle).for_reader(turtle_file.as_ref()) {
24//!     serializer.serialize_quad(&quad.unwrap()).unwrap();
25//! }
26//! assert_eq!(serializer.finish().unwrap(), ntriples_file);
27//! ```
28
29mod format;
30pub mod read;
31pub mod write;
32
33#[allow(deprecated)]
34pub use self::format::{DatasetFormat, GraphFormat};
35#[allow(deprecated)]
36pub use self::read::{DatasetParser, GraphParser};
37#[allow(deprecated)]
38pub use self::write::{DatasetSerializer, GraphSerializer};
39pub use oxrdfio::{
40    JsonLdProfile, JsonLdProfileSet, LoadedDocument, RdfFormat, RdfParseError, RdfParser,
41    RdfSerializer, RdfSyntaxError, ReaderQuadParser, SliceQuadParser, TextPosition,
42    WriterQuadSerializer,
43};