Expand description
The context processing algorithm itself, and the pieces it is built from.
§Two implementations, one algorithm: keep sync.rs in step
This module, together with define.rs and iri.rs, holds the async
implementation of the context processing algorithm — the one that can
call the Loader to fetch remote contexts and @imported documents.
sync.rs, in this same directory, holds a second, hand-maintained
implementation of the same algorithm with async, .await and the boxed
Recursion stripped out and recursion made direct. It is used as a fast path whenever
requires_loader proves the input contains no remote @context IRI and no
@import, which is the common case in real payloads.
Which of the two runs is invisible to callers: for any input both must
produce the same active context and the same error. A change to the
algorithm here therefore has to be mirrored in sync.rs, and a change there
mirrored back here. Nothing enforces this — the two are separate function
bodies with no shared code, so a fix applied to only one silently makes the
result depend on whether the input happened to reference a remote context.
The mirrored pairs are:
| this module | sync.rs |
|---|---|
process_context (mod.rs) | process_context_sync |
define (define.rs) | define_sync |
expand_iri_with (iri.rs) | expand_iri_with_sync |
sync.rs does guard the one class of divergence it can detect — reaching a
code path that would need the loader — by returning
Error::LoadingDocumentFailed. That protects against requires_loader
drifting out of step with the algorithm body; it says nothing about the two
implementations otherwise agreeing.
Structs§
- Defined
Term - A term’s state within a
DefinedTermstracker: either fully defined, or still being defined further up the recursion. - Defined
Terms - Tracks which terms of one context definition are already defined and which are still being defined, so that cyclic definitions can be detected.
- Malformed
Iri - Warning reporting that a value expanded to something that is not a valid IRI.
- Merged
- A context definition viewed together with the definition it pulls in through
@import. - Merged
Bindings - Iterator over the term definitions of a
Mergedcontext definition. - Reject
Vocab - A term could only be expanded through the vocabulary mapping, while
Options::vocabwas set toAction::Reject.
Enums§
- Action
- How strictly to treat a term whose expansion is questionable.
Functions§
- define
- Runs the create term definition algorithm for
term, adding the resulting definition toactive_context. - expand_
iri_ simple - Expands
valueinto an IRI using only the term definitionsactive_contextalready has. - expand_
iri_ with - Runs the IRI expansion algorithm on
value, defining terms oflocal_contexton demand.
Type Aliases§
- Expand
IriResult - Result of
expand_iri_with. - IriExpansion
Result - Result of expanding a term into an IRI without a loader.