pub struct Registry { /* private fields */ }
Expand description
The registry for space-efficient storage of type identifiers and definitions.
The registry consists of a cache for type identifiers and definitions.
When adding a type to the registry, all of its sub-types are registered recursively as well. A type is considered a sub-type of another type if it is used by its identifier or structure.
§Note
A type can be a sub-type of itself. In this case the registry has a builtin mechanism to stop recursion and avoid going into an infinite loop.
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn register_type(&mut self, ty: &MetaType) -> UntrackedSymbol<TypeId>
pub fn register_type(&mut self, ty: &MetaType) -> UntrackedSymbol<TypeId>
Registers the given type into the registry and returns its associated type ID symbol.
§Note
Due to safety requirements the returns type ID symbol cannot be used later to resolve back to the associated type definition. However, since this facility is going to be used for serialization purposes this functionality isn’t needed anyway.
Sourcepub fn register_types<I>(&mut self, iter: I) -> Vec<UntrackedSymbol<TypeId>>where
I: IntoIterator<Item = MetaType>,
pub fn register_types<I>(&mut self, iter: I) -> Vec<UntrackedSymbol<TypeId>>where
I: IntoIterator<Item = MetaType>,
Calls register_type
for each MetaType
in the given iter
.
Sourcepub fn map_into_portable<I, T>(&mut self, iter: I) -> Vec<T::Output>where
I: IntoIterator<Item = T>,
T: IntoPortable,
pub fn map_into_portable<I, T>(&mut self, iter: I) -> Vec<T::Output>where
I: IntoIterator<Item = T>,
T: IntoPortable,
Converts an iterator into a Vec of the equivalent portable representations.
Sourcepub fn types(
&self,
) -> impl Iterator<Item = (&UntrackedSymbol<TypeId>, &Type<PortableForm>)>
pub fn types( &self, ) -> impl Iterator<Item = (&UntrackedSymbol<TypeId>, &Type<PortableForm>)>
Returns an iterator over the types with their keys