pub struct TypeResolver { /* private fields */ }Expand description
Registry for managing and resolving custom types
Types are organized per spec (keyed by Arc
Implementations§
Source§impl TypeResolver
impl TypeResolver
pub fn new() -> Self
Sourcepub fn register_all(&mut self, spec: &Arc<LemmaSpec>) -> Vec<Error>
pub fn register_all(&mut self, spec: &Arc<LemmaSpec>) -> Vec<Error>
Register all named types from a spec (skips inline types).
Sourcepub fn resolve(
&self,
all_specs: impl IntoIterator<Item = Arc<LemmaSpec>>,
) -> (HashMap<Arc<LemmaSpec>, ResolvedSpecTypes>, Vec<Error>)
pub fn resolve( &self, all_specs: impl IntoIterator<Item = Arc<LemmaSpec>>, ) -> (HashMap<Arc<LemmaSpec>, ResolvedSpecTypes>, Vec<Error>)
Resolve all named types for every spec and validate their specifications. Produces an entry for every spec (even those without named types) because every spec needs a unit_index containing at least the primitive ratio units.
Sourcepub fn register_type(
&mut self,
spec: &Arc<LemmaSpec>,
def: TypeDef,
) -> Result<(), Error>
pub fn register_type( &mut self, spec: &Arc<LemmaSpec>, def: TypeDef, ) -> Result<(), Error>
Register a user-defined type for a given spec (keyed by Arc
Sourcepub fn resolve_types(
&self,
spec: &Arc<LemmaSpec>,
) -> Result<ResolvedSpecTypes, Vec<Error>>
pub fn resolve_types( &self, spec: &Arc<LemmaSpec>, ) -> Result<ResolvedSpecTypes, Vec<Error>>
Resolve all types for a certain spec (keyed by Arc
Sourcepub fn resolve_named_types(
&self,
spec: &Arc<LemmaSpec>,
) -> Result<ResolvedSpecTypes, Vec<Error>>
pub fn resolve_named_types( &self, spec: &Arc<LemmaSpec>, ) -> Result<ResolvedSpecTypes, Vec<Error>>
Resolve only named types (for validation before inline type definitions are registered).
Sourcepub fn resolve_inline_types(
&self,
spec: &Arc<LemmaSpec>,
existing: ResolvedSpecTypes,
) -> Result<ResolvedSpecTypes, Vec<Error>>
pub fn resolve_inline_types( &self, spec: &Arc<LemmaSpec>, existing: ResolvedSpecTypes, ) -> Result<ResolvedSpecTypes, Vec<Error>>
Resolve only inline type definitions and merge them into an existing
ResolvedSpecTypes that already contains the named types.
Sourcepub fn resolve_primitive_type(&self, name: &str) -> Option<TypeSpecification>
pub fn resolve_primitive_type(&self, name: &str) -> Option<TypeSpecification>
Resolve a primitive type by name
Trait Implementations§
Source§impl Clone for TypeResolver
impl Clone for TypeResolver
Source§fn clone(&self) -> TypeResolver
fn clone(&self) -> TypeResolver
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TypeResolver
impl Debug for TypeResolver
Auto Trait Implementations§
impl Freeze for TypeResolver
impl RefUnwindSafe for TypeResolver
impl Send for TypeResolver
impl Sync for TypeResolver
impl Unpin for TypeResolver
impl UnsafeUnpin for TypeResolver
impl UnwindSafe for TypeResolver
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more