pub struct GraphParser { /* private fields */ }
๐Deprecated since 0.4.0: use RdfParser instead
Expand description
Parsers for RDF graph serialization formats.
It currently supports the following formats:
use oxigraph::io::{GraphFormat, GraphParser};
let file = "<http://example.com/s> <http://example.com/p> <http://example.com/o> .";
let parser = GraphParser::from_format(GraphFormat::NTriples);
let triples = parser
.read_triples(file.as_bytes())
.collect::<Result<Vec<_>, _>>()?;
assert_eq!(triples.len(), 1);
assert_eq!(triples[0].subject.to_string(), "<http://example.com/s>");
Implementationsยง
Sourceยงimpl GraphParser
impl GraphParser
Sourcepub fn from_format(format: GraphFormat) -> Self
pub fn from_format(format: GraphFormat) -> 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::{GraphFormat, GraphParser};
let file = "</s> </p> </o> .";
let parser =
GraphParser::from_format(GraphFormat::Turtle).with_base_iri("http://example.com")?;
let triples = parser
.read_triples(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_triples<R: Read>(self, reader: R) -> TripleReader<R> โ
pub fn read_triples<R: Read>(self, reader: R) -> TripleReader<R> โ
Executes the parsing itself on a Read
implementation and returns an iterator of triples.
Auto Trait Implementationsยง
impl Freeze for GraphParser
impl RefUnwindSafe for GraphParser
impl Send for GraphParser
impl Sync for GraphParser
impl Unpin for GraphParser
impl UnwindSafe for GraphParser
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