pub struct DatasetParser { /* private fields */ }
๐Deprecated since 0.4.0: use RdfParser instead
Expand description
A parser for RDF dataset serialization formats.
It currently supports the following formats:
use oxigraph::io::{DatasetFormat, DatasetParser};
let file = "<http://example.com/s> <http://example.com/p> <http://example.com/o> <http://example.com/g> .";
let parser = DatasetParser::from_format(DatasetFormat::NQuads);
let quads = parser.read_quads(file.as_bytes()).collect::<Result<Vec<_>,_>>()?;
assert_eq!(quads.len(), 1);
assert_eq!(quads[0].subject.to_string(), "<http://example.com/s>");
Implementationsยง
Sourceยงimpl DatasetParser
impl DatasetParser
Sourcepub fn from_format(format: DatasetFormat) -> Self
pub fn from_format(format: DatasetFormat) -> Self
Builds a parser for the given format.
Sourcepub fn with_base_iri(
self,
base_iri: impl Into<String>,
) -> Result<Self, IriParseError>
pub fn with_base_iri( self, base_iri: impl Into<String>, ) -> Result<Self, IriParseError>
Provides an IRI that could be used to resolve the file relative IRIs.
use oxigraph::io::{DatasetFormat, DatasetParser};
let file = "<g> { </s> </p> </o> }";
let parser =
DatasetParser::from_format(DatasetFormat::TriG).with_base_iri("http://example.com")?;
let triples = parser
.read_quads(file.as_bytes())
.collect::<Result<Vec<_>, _>>()?;
assert_eq!(triples.len(), 1);
assert_eq!(triples[0].subject.to_string(), "<http://example.com/s>");
Sourcepub fn read_quads<R: Read>(self, reader: R) -> QuadReader<R> โ
pub fn read_quads<R: Read>(self, reader: R) -> QuadReader<R> โ
Executes the parsing itself on a Read
implementation and returns an iterator of quads.
Auto Trait Implementationsยง
impl Freeze for DatasetParser
impl RefUnwindSafe for DatasetParser
impl Send for DatasetParser
impl Sync for DatasetParser
impl Unpin for DatasetParser
impl UnwindSafe for DatasetParser
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more