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
impl IdentCache
Sourcepub fn add_schema(&mut self, ns: NamespaceId, schema: SchemaId)
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.
Sourcepub fn add_dependency(
&mut self,
schema: SchemaId,
dependency: Dependency<SchemaId>,
) -> bool
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.
Sourcepub fn add_global_namespace(&mut self, ns: NamespaceId)
pub fn add_global_namespace(&mut self, ns: NamespaceId)
Add a namespace that is always searched when trying to resolve an identifier.
Sourcepub fn resolve(&self, ident: TypeIdent) -> Result<TypeIdent, InterpreterError>
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.
Sourcepub fn resolve_allow_unknown(
&self,
ident: TypeIdent,
) -> Result<TypeIdent, InterpreterError>
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.
Sourcepub fn schema_set(&self, schema: SchemaId) -> SchemaSetIter<'_>
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.
Sourcepub fn resolve_for_schema(
&self,
schema: SchemaId,
ident: TypeIdent,
) -> Result<TypeIdent, InterpreterError>
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.