pub struct ProcessingStack<I> { /* private fields */ }Expand description
The chain of remote context URLs currently being processed.
This is the specification’s remote contexts array. It serves two purposes:
spotting a context that includes itself, and bounding the length of a remote
context chain at MAX_REMOTE_CONTEXTS. Whether it is empty also tells the
algorithm whether the context being processed came from a remote document,
which is what decides if its @base entry applies.
Implemented as an immutable singly-linked list behind Arcs, so the copy
each recursive call receives is a pointer bump rather than a clone of the
chain.
Every copy of a stack also shares one record of the contexts dereferenced since the stack was created, which is how one run of the algorithm honours step 5.2.4: “If context was previously dereferenced, then the processor MUST NOT do a further dereference”. The chain is per branch of the recursion; the record is per run.
Implementations§
Source§impl<I> ProcessingStack<I>
impl<I> ProcessingStack<I>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty stack, meaning no remote context is being processed, with an empty record of dereferenced contexts.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks whether no remote context has been entered, i.e. the context being processed is not itself remote.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of remote contexts on the stack.
Walks the chain, so this is linear in the stack depth.
Sourcepub fn cycle(&self, url: &I) -> boolwhere
I: PartialEq,
pub fn cycle(&self, url: &I) -> boolwhere
I: PartialEq,
Checks whether url is already on the stack, meaning entering it would
close a loop.
Sourcepub fn push(&mut self, url: I) -> boolwhere
I: PartialEq,
pub fn push(&mut self, url: I) -> boolwhere
I: PartialEq,
Pushes url onto the stack, unless it is already there.
Returns true when the URL was added, and false when it was already on
the stack and nothing changed. What false means is version-dependent:
JSON-LD 1.0 treats it as a recursive context inclusion error, while 1.1
skips the context only while validating a scoped context (step 5.2.2)
and otherwise processes it again, which is Self::enter.
Sourcepub fn enter(&mut self, url: I)
pub fn enter(&mut self, url: I)
Pushes url onto the stack whether or not it is already there.
This is step 5.2.3’s “add context to remote contexts”: under JSON-LD 1.1
a context named again outside scoped-context validation is processed
again, and each processing counts toward MAX_REMOTE_CONTEXTS.
Trait Implementations§
Source§impl<I> Clone for ProcessingStack<I>
impl<I> Clone for ProcessingStack<I>
Auto Trait Implementations§
impl<I> !RefUnwindSafe for ProcessingStack<I>
impl<I> !UnwindSafe for ProcessingStack<I>
impl<I> Freeze for ProcessingStack<I>
impl<I> Send for ProcessingStack<I>
impl<I> Sync for ProcessingStack<I>
impl<I> Unpin for ProcessingStack<I>
impl<I> UnsafeUnpin for ProcessingStack<I>where
Option<Arc<StackNode<I>>>: UnsafeUnpin,
Arc<Mutex<RawMutex, HashMap<I, Arc<Context>>>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
Source§fn as_unordered(&self) -> &Unordered<T>
fn as_unordered(&self) -> &Unordered<T>
Unordered reference.