Skip to main content

Processed

Struct Processed 

Source
pub struct Processed<'l, T = IriBuf, B = BlankIdBuf> {
    pub unprocessed: &'l Context,
    pub processed: Context<T, B>,
}
Expand description

An active context paired with a borrow of the @context it was built from.

Both halves are needed downstream: the active context drives expansion and compaction, while the original, syntactic context is what compaction embeds into its output so the result round-trips.

Derefs to the active context, so a caller that only needs that can use it directly.

Fields§

§unprocessed: &'l Context

The context as it was written.

§processed: Context<T, B>

The active context it processed into.

Implementations§

Source§

impl<'l, T, B> Processed<'l, T, B>

Source

pub fn new(unprocessed: &'l Context, processed: Context<T, B>) -> Self

Pairs an active context with the @context it was built from.

Source

pub fn unprocessed(&self) -> &'l Context

Returns the @context as it was written, before processing.

Source

pub fn into_processed(self) -> Context<T, B>

Discards the original @context and returns just the active context.

Source

pub fn as_ref(&self) -> ProcessedRef<'l, '_, T, B>

Borrows both halves as a ProcessedRef.

Source

pub fn into_owned(self) -> ProcessedOwned<T, B>

Clones the original @context so the pair no longer borrows it.

Methods from Deref<Target = Context<T, B>>§

Source

pub fn with_private_caches(&self) -> Context<T, B>
where T: Clone, B: Clone,

Returns a copy of this context whose IRI memoisation caches are private to the copy.

Self::term_resolution_cache maps a term to an already-resolved Term, which carries T-typed identifiers. Sharing it across vocabulary forks is unsound: a term that one fork resolved by interning a new IRI would be served to another fork, where that identifier denotes something else entirely — or nothing. Concurrent expansion therefore gives each task a context of its own.

Only the caches are fresh. Definitions, prefix terms and keyword aliases are shared through their Arcs: they are derived from the context’s own definitions, whose identifiers every fork inherits, so they stay valid. The same reasoning covers the inverse context.

Source

pub fn processing_mode(&self) -> ProcessingMode

Returns the processing mode this context was processed under.

Source

pub fn set_processing_mode(&mut self, mode: ProcessingMode)

Sets the processing mode of this context.

Source

pub fn get<Q>(&self, term: &Q) -> Option<TermDefinitionRef<'_, T, B>>
where Key: Borrow<Q>, KeywordType: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns a reference to the given term definition, if any.

Source

pub fn get_normal<Q>(&self, term: &Q) -> Option<&NormalTermDefinition<T, B>>
where Key: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns a reference to the given term normal definition, if any.

Source

pub fn get_type(&self) -> Option<&TypeTermDefinition>

Returns a reference to the @type definition, if any.

Source

pub fn contains_term<Q>(&self, term: &Q) -> bool
where Key: Borrow<Q>, KeywordType: Borrow<Q>, Q: Hash + Eq + ?Sized,

Checks if the given term is defined.

Source

pub fn original_base_url(&self) -> Option<&T>

Returns the original base URL of the context.

Source

pub fn base_iri(&self) -> Option<&T>

Returns the base IRI of the context.

Source

pub fn vocabulary(&self) -> Option<&Term<T, B>>

Returns the @vocab value, if any.

Source

pub fn default_language(&self) -> Option<&LenientLangTag>

Returns the default @language value.

Source

pub fn default_base_direction(&self) -> Option<Direction>

Returns the default @direction value.

Source

pub fn previous_context(&self) -> Option<&Context<T, B>>

Returns a reference to the previous context.

Source

pub fn definitions_arc_ptr(&self) -> *const Definitions<T, B>

Returns the address of the Arc backing the term definitions.

Two contexts that share this pointer share the exact same definitions (copy-on-write via Arc::make_mut). Useful as a cheap fingerprint for memoization keys.

Source

pub fn previous_context_arc_ptr(&self) -> *const Context<T, B>

Returns the address of the Arc backing the previous context, or null when there is none. See Self::definitions_arc_ptr.

Source

pub fn len(&self) -> usize

Returns the number of terms defined.

Source

pub fn is_empty(&self) -> bool

Checks if no terms are defined.

Source

pub fn definitions(&self) -> &Definitions<T, B>

Returns a handle to the term definitions.

Source

pub fn has_protected_items(&self) -> bool

Checks if the context has a protected definition.

Source

pub fn inverse(&self) -> &InverseContext<T, B>
where T: Clone + Hash + Eq, B: Clone + Hash + Eq,

Returns the inverse context, computing and caching it on first access.

Source

pub fn prefix_terms(&self) -> &[(Key, Arc<Term<T, B>>)]

Returns the term definitions whose prefix flag is true, each paired with its IRI mapping.

The mapping is carried alongside the key so that compaction’s candidate loop does not have to look the definition back up — which would re-hash the very key this list just handed it. Definitions with no IRI mapping cannot form a compact IRI and are left out.

Lazily computed and cached; invalidated whenever a definition is added, removed, or replaced.

Source

pub fn compact_iri_cache( &self, ) -> &ShardedMemo<(Term<T, B>, bool, bool, ProcessingMode), Option<Arc<str>>>

Returns the per-context memoization map for the compact-IRI algorithm.

The cache stores results keyed on (var, vocab, reverse, mode). It is invalidated whenever the context’s term definitions, base IRI, vocabulary, language, or direction change, since those affect compaction output.

Source

pub fn term_resolution_cache(&self) -> &ShardedMemo<Box<str>, Arc<Term<T, B>>>

Returns the per-context memoization map for IRI expansion of term keys.

Maps the input string to the resolved Arc<Term>. Populated only by the dominant key-expansion call shape (vocab=Some(Keep), document_relative=false); other shapes bypass this cache. Invalidated alongside the compact-IRI / inverse caches whenever the context’s term definitions, base IRI, vocabulary, language, or direction change.

Source

pub fn keyword_aliases_or_init<F>( &self, mode: ProcessingMode, init: F, ) -> &KeywordAliases
where F: FnOnce() -> KeywordAliases,

Returns the cached keyword aliases of this context for the given processing mode, computing them via init on first access. The closure runs once per (context, mode); subsequent calls return the cached value. Aliases are cached per mode because compact-IRI selection is mode-dependent.

Source

pub fn set_normal( &mut self, key: Key, definition: Option<NormalTermDefinition<T, B>>, ) -> Option<NormalTermDefinition<T, B>>
where T: Clone, B: Clone,

Sets the normal definition for the given term key.

Source

pub fn set_type( &mut self, type_: Option<TypeTermDefinition>, ) -> Option<TypeTermDefinition>
where T: Clone, B: Clone,

Sets the @type definition.

Source

pub fn set_base_iri(&mut self, iri: Option<T>)

Sets the base IRI.

Source

pub fn set_vocabulary(&mut self, vocab: Option<Term<T, B>>)

Sets the @vocab value.

Source

pub fn set_default_language(&mut self, lang: Option<LenientLangTagBuf>)

Sets the default @language value.

Source

pub fn set_default_base_direction(&mut self, dir: Option<Direction>)

Sets the default @direction value.

Source

pub fn set_previous_context(&mut self, previous: Context<T, B>)

Sets the previous context.

Trait Implementations§

Source§

impl<T, B> Deref for Processed<'_, T, B>

Source§

type Target = Context<T, B>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T, B> DerefMut for Processed<'_, T, B>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'l, T = Iri<String>, B = BlankIdBuf> !RefUnwindSafe for Processed<'l, T, B>

§

impl<'l, T = Iri<String>, B = BlankIdBuf> !UnwindSafe for Processed<'l, T, B>

§

impl<'l, T, B> Freeze for Processed<'l, T, B>
where Context<T, B>: Freeze,

§

impl<'l, T, B> Send for Processed<'l, T, B>
where Context<T, B>: Send,

§

impl<'l, T, B> Sync for Processed<'l, T, B>
where Context<T, B>: Sync,

§

impl<'l, T, B> Unpin for Processed<'l, T, B>
where Context<T, B>: Unpin,

§

impl<'l, T, B> UnsafeUnpin for Processed<'l, T, B>
where Context<T, B>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> BorrowUnordered for T

Source§

fn as_unordered(&self) -> &Unordered<T>

Views this value as an Unordered reference.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, C> FromWithContext<T, C> for T

Source§

fn from_with(value: T, _context: &C) -> T

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U, C> IntoWithContext<U, C> for T
where U: FromWithContext<T, C>,

Source§

fn into_with(self, context: &C) -> U

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U, C> TryFromWithContext<U, C> for T
where U: IntoWithContext<T, C>,

Source§

type Error = !

Source§

fn try_from_with( value: U, context: &C, ) -> Result<T, <T as TryFromWithContext<U, C>>::Error>

Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U, C> TryIntoWithContext<U, C> for T
where U: TryFromWithContext<T, C>,

Source§

type Error = <U as TryFromWithContext<T, C>>::Error

Source§

fn try_into_with( self, context: &C, ) -> Result<U, <T as TryIntoWithContext<U, C>>::Error>

Source§

impl<T> WithContext for T
where T: ?Sized,

Source§

fn with<C>(&self, context: C) -> Contextual<&T, C>

Source§

fn into_with<C>(self, context: C) -> Contextual<T, C>
where T: Sized,