pub struct GraphExport<'a> { /* private fields */ }Expand description
GraphExport provides RDF serialization and export operations.
Uses Oxigraph’s RdfSerializer API following core team best practices for
efficient and format-compliant RDF serialization.
Supports exporting graphs to files and streams in all RDF formats:
- Turtle (.ttl) - Human-readable format with prefix support
- N-Triples (.nt) - Line-based format with full IRIs
- RDF/XML (.rdf, .xml) - XML-based RDF serialization
- TriG (.trig) - Turtle format with named graph support
- N-Quads (.nq) - N-Triples format with named graph support
§Examples
§Export to file
use crate::graph::{Graph, GraphExport};
use oxigraph::io::RdfFormat;
let graph = Graph::new()?;
graph.insert_turtle(r#"
@prefix ex: <http://example.org/> .
ex:alice a ex:Person .
"#)?;
let export = GraphExport::new(&graph);
export.write_to_file("output.ttl", RdfFormat::Turtle)?;§Export to string
use crate::graph::{Graph, GraphExport};
use oxigraph::io::RdfFormat;
let graph = Graph::new()?;
let export = GraphExport::new(&graph);
let turtle = export.write_to_string(RdfFormat::Turtle)?;
println!("{}", turtle);Implementations§
Source§impl<'a> GraphExport<'a>
impl<'a> GraphExport<'a>
Sourcepub fn write_to_writer<W: Write>(
&self,
writer: W,
format: RdfFormat,
) -> Result<()>
pub fn write_to_writer<W: Write>( &self, writer: W, format: RdfFormat, ) -> Result<()>
Write the graph to a writer in the specified format.
Uses Oxigraph’s Store API appropriately:
- For graph formats (Turtle, N-Triples, RDF/XML): manually serializes default graph only
- For dataset formats (TriG, N-Quads): uses
dump_to_writerfor all graphs
§Arguments
writer- Writer to write toformat- RDF format to use (Turtle, N-Triples, RDF/XML, TriG, N-Quads)
Sourcepub fn write_to_string(&self, format: RdfFormat) -> Result<String>
pub fn write_to_string(&self, format: RdfFormat) -> Result<String>
Sourcepub fn write_to_file_auto<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn write_to_file_auto<P: AsRef<Path>>(&self, path: P) -> Result<()>
Write the graph to a file, auto-detecting format from extension.
Supported extensions:
.ttl,.turtle- Turtle.nt,.ntriples- N-Triples.rdf,.xml- RDF/XML.trig- TriG.nq,.nquads- N-Quads
§Arguments
path- Path to the output file
§Errors
Returns an error if:
- The file extension is unsupported
- The file cannot be created or written
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for GraphExport<'a>
impl<'a> !UnwindSafe for GraphExport<'a>
impl<'a> Freeze for GraphExport<'a>
impl<'a> Send for GraphExport<'a>
impl<'a> Sync for GraphExport<'a>
impl<'a> Unpin for GraphExport<'a>
impl<'a> UnsafeUnpin for GraphExport<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> EvidenceKind for T
impl<T> EvidenceKind for T
default fn kind_label(&self) -> &'static str
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more