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 |
R+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
.
An example, reading an existing NTriple file.
use rdftk_io::nt::reader::NTriplesReader;
use rdftk_io::GraphReader;
use rdftk_memgraph::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();
- Feature: better
Literal
handling in Turtle;- write only the lexical form for numeric and boolean literals,
- write prefixed-names instead of full IRI where possible.
- Feature: added
GraphWriter
andDataSetWriter
traits so that clients need not importobjio
.
- Feature: moved to new v0.5 core package.
- Tests: all tests now passing.
- Feature: moved to new
rdftk_core
package. - Refactor: moved reader/writer traits to new
objio
crate. - Build: updated Rust edition from 2018 to 2021.
- Build: cargo audit/outdated/udeps
- Docs: added API docs as much as possible.
- Docs: run markuplint on
README.md
.
- Added JSON reader.
- Updated rdftk_core dependency to 0.3.0, this is a significant API change.
- All read operations require a graph factory now.
- Added unicode escape handling into the IRI parsing.
- All W3C test cases for NTriples now passing.
- Removed local error module, using core error types now.
- Using new style interfaces, a consistent use of traits and trait reference types.
- Have a working NTriple parser.
- Using rdftk_core 0.2, this has changes in the signature of both Graph and
DataSet traits.
- This results in changes to both GraphWriter and DataSetWriter traits.
- Applied a lot more warnings in lib.rs
- Fixed resulting Clippy suggestions.
- Made all modules have separate reader/writer sub-modules.
- Put all modules behind features.
- Added JSON writer.
- Re-write NQuad writer to write datasets.
- Re-wrote NTripe writer to use NQuad writer.
- Fixed formatting in Turtle writer.
- Added XML writer.
- Internal change to use
StatementRef
.
- API changes in core crate:
- Altered
PrefixMappings::compress
andPrefixMappings::expand
to take references.
- Altered
- Made all
IRI
intoIRIRef
.
- Made all local dependencies only major/minor valued.
- First release.
- Provides write support only for N-Triples, N-Quads, and GraphViz.
- The core; N-Triples, N-Quads, N3, and Turtle need read and write support.
- The extended core; RDF/XML, JSON-LD, and RDFa need read and write support.
- The rest; RDF/JSON, TriG, HDT, and BinaryRDF will be implemended as needed.