vertep_store/vocab.rs
1//! The `vt:` terms the storage layer writes itself.
2//!
3//! These are the bookkeeping terms of the journal protocol: the type and stamps of a journal
4//! entry, the actor's head, the fencing epoch per scope and the projector's position. They live
5//! in the Vertep namespace ([`VT`]) so that entries use the runtime ontology's terms; the
6//! runtime vocabulary module in `vertep-rdf` is expected to declare the same IRIs.
7
8use oxrdf::NamedNode;
9
10/// The Vertep namespace (equal to `vertep_core::ir::VT_NS`).
11pub const VT: &str = "https://w3id.org/vertep/vt#";
12
13/// The `rdf:type` IRI.
14pub const RDF_TYPE: &str = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
15
16/// `vt:JournalEntry`: the class of journal entries.
17pub const JOURNAL_ENTRY: &str = "https://w3id.org/vertep/vt#JournalEntry";
18/// `vt:actor`: from a journal entry to the address of the actor whose journal it is in.
19pub const ACTOR: &str = "https://w3id.org/vertep/vt#actor";
20/// `vt:position`: the journal position of an entry (`xsd:integer`, from 1, no gaps).
21pub const POSITION: &str = "https://w3id.org/vertep/vt#position";
22/// `vt:head`: the position of the last entry of an actor's journal (cardinality one).
23pub const HEAD: &str = "https://w3id.org/vertep/vt#head";
24/// `vt:fencingEpoch`: the highest fencing epoch accepted for a scope (cardinality one).
25pub const FENCING_EPOCH: &str = "https://w3id.org/vertep/vt#fencingEpoch";
26/// `vt:projectedPosition`: the last journal position of an actor written to a graph store.
27pub const PROJECTED_POSITION: &str = "https://w3id.org/vertep/vt#projectedPosition";
28/// The graph in which a [`crate::Projector`] records its positions.
29pub const PROJECTION_GRAPH: &str = "https://w3id.org/vertep/vt#projection";
30
31/// A [`NamedNode`] for one of the IRI constants of this module.
32pub fn node(iri: &str) -> NamedNode {
33 NamedNode::new_unchecked(iri)
34}
35
36#[cfg(test)]
37mod tests {
38 use super::*;
39
40 #[test]
41 fn terms_are_in_the_vt_namespace() {
42 for iri in [
43 JOURNAL_ENTRY,
44 ACTOR,
45 POSITION,
46 HEAD,
47 FENCING_EPOCH,
48 PROJECTED_POSITION,
49 PROJECTION_GRAPH,
50 ] {
51 assert!(iri.starts_with(VT), "{iri}");
52 assert!(NamedNode::new(iri).is_ok());
53 }
54 }
55}