pub struct Registry { /* private fields */ }Expand description
The contexts available to a processing run.
Parsing the bundled documents costs a few hundred microseconds, so build one
registry and keep it rather than building one per document. A clone
shares those documents, so a clone given a few more with
Registry::with costs only what was added.
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn bundled() -> Self
pub fn bundled() -> Self
Every context ojak ships, and nothing else.
§Panics
Never, for the bundled documents: they are parsed by a test.
Sourcepub fn empty() -> Self
pub fn empty() -> Self
An empty registry, resolving nothing.
Useful for asking what a document means on its own terms: with no
registry every @context IRI goes unresolved and only inline term
definitions apply.
Sourcepub fn with(self, iri: impl Into<String>, document: Value) -> Self
pub fn with(self, iri: impl Into<String>, document: Value) -> Self
Add a context of the caller’s own.
The value is the whole context document — an object with an
@context member — matching what the IRI would have served.
Sourcepub fn known_iris(&self) -> Vec<String>
pub fn known_iris(&self) -> Vec<String>
Every IRI this registry answers to, including aliases.