Skip to main content

IdentCache

Struct IdentCache 

Source
pub struct IdentCache { /* private fields */ }
Expand description

Cache that keeps track of different TypeIdentifiers.

The IdentCache is created by the Interpreter (see exec_interpreter_with_ident_cache).

It contains all types that are created during the interpretation of the provided schemas. It is able to resolve half qualified types identifiers (identifiers with a missing schema or namespace ID), to the actual identifier that is used to identify a MetaType inside the MetaTypes structure.

Implementations§

Source§

impl IdentCache

Source

pub fn insert(&mut self, ident: TypeIdent)

Insert the passed identifier into the cache.

Source

pub fn add_schema(&mut self, ns: NamespaceId, schema: SchemaId)

Add a schema to the cache.

This is required to be able to resolve identifiers that are defined in the schema, and to be able to add dependencies to it.

Source

pub fn add_dependency( &mut self, schema: SchemaId, dependency: Dependency<SchemaId>, ) -> bool

Add a dependency between two schemas.

This means that when trying to resolve an identifier for schema, the cache will also search for it in dependency.

§Returns

Returns true if the dependency was added, or false if it already existed or if schema is not known to the cache.

Source

pub fn add_global_namespace(&mut self, ns: NamespaceId)

Add a namespace that is always searched when trying to resolve an identifier.

Source

pub fn resolve(&self, ident: TypeIdent) -> Result<TypeIdent, InterpreterError>

Try to resolve the passed identifier to an actual existing identifier.

This function will lookup the passed identifier in the global context. This means that all schemas that are known to the cache will be searched for a matching type, and if multiple matches are found, an InterpreterError::AmbiguousType error will be returned.

§Errors

Returns a InterpreterError::UnknownType if the identifier is not known to the cache, or InterpreterError::AmbiguousType if multiple identifiers matches the passed one.

Source

pub fn resolve_allow_unknown( &self, ident: TypeIdent, ) -> Result<TypeIdent, InterpreterError>

Same as resolve, but instead of returning a UnknownType error for unknown identifiers it returns the original identifier.

§Errors

Returns InterpreterError::AmbiguousType if multiple identifiers matches the passed one.

Source

pub fn schema_set(&self, schema: SchemaId) -> SchemaSetIter<'_>

Get an iterator over all identifiers that are known to the cache in the context of the specified schema set. Not including the global namespaces, the unknown schema and the identifiers referenced by a xs:include.

Source

pub fn resolve_for_schema( &self, schema: SchemaId, ident: TypeIdent, ) -> Result<TypeIdent, InterpreterError>

Try to resolve the passed identifier to an actual existing identifier.

In contrast to resolve, this function will search for the passed identifier in the context of the specified schema. This means that it will try to resolve the type inside schema, and if it is not found, it will try to resolve it in its dependencies. As soon as a match is found, it will be returned, and the search will not continue, so no error will be raised if multiple matches are found.

§Errors

Returns a InterpreterError::UnknownType if the identifier is not known to the cache.

Trait Implementations§

Source§

impl Debug for IdentCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for IdentCache

Source§

fn default() -> IdentCache

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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<X> AsAny for X
where X: 'static,

Source§

fn into_any(self: Box<X>) -> Box<dyn Any>

Convert the boxed object into a boxed any.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Get a reference to the current object as Any.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Get a mutable reference to the current object as Any.
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,