Crate sophia_api

source ·
Expand description

This crate provides a foundation, as a set of traits and core types, for building interoperable implementations of RDF and Linked Data in Rust.

For an all-inclusive crate (providing actual implementations of the traits defined here), see sophia.

RDF

RDF is a data model designed to exchange knowledge on the Web in an interoperable way. Each piece of knowledge in RDF (a statement) is represented by a triple, made of three terms. A set of triples forms an RDF graph. Finally, several graphs can be grouped in a collection called a dataset, where each graph is identified by a unique name.

Generalized vs. Strict RDF model

The data model supported by this crate is in fact a superset of the RDF data model as defined by the W3C. When the distinction matters, they will be called, respectively, the generalized RDF model, and the strict RDF model.

The generalized RDF model extends RDF as follows:

  • In addition to standard RDF terms (IRIs, blank nodes and literals), Sophia supports

  • Sophia allows any kind of term in any position (subject, predicate, object, graph name).

  • Sophia allow IRIs to be relative IRI references (while in strict RDF, IRIs must be absolute).

Feature gates

  • test_macros: with this feature enabled, this crate exposes macros that can help implementors of the API to test their implementation.

Modules

  • An RDF dataset is composed of a default dataset, and zero or more named graphs, each associated with a dataset name.
  • An RDF graph, the central notion of the RDF data model, is a collection of triples.
  • Standard and custom namespaces.
  • API for parsing RDF syntaxes.
  • RDF-related languages (e.g. Turtle, SPARQL) often use prefixes to shorten IRIs. This crate provides generic traits and types to handle prefix maps.
  • General-use types and traits from the Sophia API.
  • A quad expresses a single fact within a context. Quads are like RDF triples augmented with an optional graph name.
  • API for serializing RDF syntaxes.
  • A source yields items, and may also fail in the process. This module provides two specialized kinds of source: TripleSource and QuadSource.
  • Common traits for working with SPARQL.
  • I define how RDF terms (such as IRIs, blank nodes and literals) are represented in Sophia.
  • I define how RDF triples are represented in Sophia.

Macros

Structs

  • Re-export MownStr to avoid dependency version mismatch.