Crate rdftk_io[−][src]
Expand description
This crate provides traits for reading and writing
Statement
s and Graph
s as well as implementations of these for common representations.
The following are some well-known formats (see Wikipedia
for a description of different serializations), support is indicated in the final column with
an R for read support and W for write support. One additional module, dot
allows for the
creation of GraphViz dot files for a visualization of a graph’s structure.
Module | Name | MIME Type | R/W |
---|---|---|---|
nt | RDF 1.1 N-Triples; A line-based syntax for an RDF graph | application/n-triples | R+W |
nq | RDF 1.1 N-Quads; A line-based syntax for RDF datasets | application/n-quads | W |
turtle | RDF 1.1 Turtle; Terse RDF Triple Language | text/turtle | W |
trig | RDF 1.1 TriG; RDF Dataset Language | application/trig | |
xml | RDF 1.1 XML Syntax | application/rdf+xml | W |
json | RDF 1.1 JSON Alternate Serialization | application/rdf+json | W |
n3 | Notation3 (N3): A readable RDF syntax | text/rdf+n3 | W |
TBD | Binary RDF Representation for Publication and Exchange (HDT) | N/A | |
TBD | RDF Binary using Apache Thrift | application/x-binary-rdf | |
TBD | JSON-LD 1.1; A JSON-based Serialization for Linked Data | application/ld+json | |
TBD | RDFa Core 1.1 - Third Edition | text/html |
Each module will also provide public constants NAME
, FILE_EXTENSION
, and MIME_TYPE
.
Example
An example, reading an existing NTriple file.
use rdftk_io::nt::reader::NTriplesReader; use rdftk_io::GraphReader; use rdftk_core::simple::graph_factory; use std::fs::File; use std::path::PathBuf; let file_path = PathBuf::from("tests/w3c/nt/literal.nt"); let mut file = File::open(file_path).unwrap(); let reader = NTriplesReader::default(); let graph = reader.read(&mut file, graph_factory()).unwrap();
Modules
json | Provides for writing a |
nq | Provides for reading and writing a |
nt | Provides for reading and writing a |
xml | Provides for writing out in the RDF 1.1 XML Syntax format. |
Traits
DataSetWriter | Write all |
GraphReader | Read an entire |
GraphWriter | Write all |
Functions
write_data_set_to_string | A convenience function that will return a String containing the output of the |
write_graph_to_string | A convenience function that will return a String containing the output of the |