[−][src]Module rome::graph
The main module of this crate. It has traits for RDF graphs.
RDF graphs consist of triples: a subject, a predicate, and an object. Triples are also called statements: A triple says something about something. For example:
@prefix nco: <http://www.semanticdesktop.org/ontologies/2007/03/22/nco#> .
@prefix nfo: <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#> .
@prefix : <http://example.org/> .
<hello_world.rs> a nfo:SourceCode .
<hello_world.rs> nfo:programmingLanguage "Rust"@en .
<hello_world.rs> nco:creator :alice .
:alice nco:hasName _:alice_name .
_:alice_name nco:nickname "alist" .
This small graph states a few things about a resource hello_world.rs
.
hello_world.rs
is a relative IRI. The first triple states that
hello_world.rs
is source code. The second statement says that it is written
in Rust. The last three triple identify the creator by nickname.
Basically a graph is a table with three columns: subject, predicate, object. In
this example the subjects are, in short form, <hello_world.rs>
, :alice
and
_:alice_name
. The first two are IRIs. They expand to full IRIs when parsed:
file:///home/alice/src/hello/hello_world.rs
and http://example.org/alice
.
These IRIs uniquely identify a resource, in this case the file
hello_world.rs
and the person Alice.
One of the subjects in the example, _:alice_name
is not an IRI but a blank
node. Blank nodes are used for subjects and objects for which no identifier is
known or needed.
The second column contains the predicates. Predicates are always IRIs. The predicate describes a relation between a subject and an object.
The third column contains the objects. An object can be a blank node, an IRI or
a literal. The value of a literal is written in quotes. A literal can have a
a datatype or a language. In the example, the literal value Rust
is
english (@en
).
The format of RDF looks very verbose like this. The form of this example is Turtle. There are also binary formats for RDF graphs such as HDT.
http://www.w3.org/TR/rdf-concepts
This module contains traits that correspond to concepts in RDF.
BlankNodePtr
, IRIPtr
and LiteralPtr
are pointers into the graph. Together they
form a Triple. The subject of a triple can be a blank node or an IRI. This is
modelled by the enum BlankNodeOrIRI
. A predicate can only be an IRI. An object
can take any kind of resource so the enum Resource encapsulates BlankNodePtr
,
IRIPtr
and LiteralPtr
.
In this module, graphs are immutable, but an new graph can be created by extending another graph (TODO).
Enums
BlankNodeOrIRI |
An enum that contains a blank node or an IRI |
Resource |
A Resource is a blank node, an IRI or a literal. |
WriterBlankNodeOrIRI |
|
WriterResource |
|
Traits
BlankNodePtr |
Instances of this trait point to a blank node in a graph. |
DatatypePtr |
A trait for a pointers to datatypes of literals in graphs. |
Graph |
An RDF graph. |
GraphWriter |
Trait for writing into a graph. |
IRIPtr |
A trait for a pointers to IRI in graphs. |
LiteralPtr |
A trait for a pointers to literals in graphs. |
ResourceTranslator |
translate from one graph to another useful for inferencing there can be a general implemenation as wel as an optimized one that's used when extending a graph by inferencing from its own content |
Triple |
Triples are fundamental to RDF. |