Skip to main content

ElementResolver

Trait ElementResolver 

Source
pub trait ElementResolver: Send + Sync {
    // Required method
    fn resolve_element(
        &self,
        name: &str,
    ) -> Result<Option<Arc<ElementSpec>>, AmbiguousElement>;
}
Expand description

An element resolver: the lookup with which a reading session turns a serialized element name back into an element value.

On the wire, an element is written by its stable type name, so this is the lookup from that name back to the element value the registry holds under it. The registry implements it; a test can use crate::dump::session::ElementTable, a set of structural elements and a map.

It need not return the structural elements: the reading environment looks names up in the reading language’s own set first (ReadEnvironment::resolve_element).

Its public path is crate::dump::session::ElementResolver.

Required Methods§

Source

fn resolve_element( &self, name: &str, ) -> Result<Option<Arc<ElementSpec>>, AmbiguousElement>

Returns the element value registered under name, or Ok(None) (not an error) when no value is registered under it.

§Errors

AmbiguousElement, which identifies the owner of each value, when several values share the name: a name is never resolved by guessing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: ElementResolver + ?Sized> ElementResolver for Arc<T>

Implementors§