Struct scale_info::Registry
source · [−]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
sourceimpl 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>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
where
I: IntoIterator<Item = MetaType>,
pub fn register_types<I>(&mut self, iter: I) -> Vec<UntrackedSymbol<TypeId>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
where
I: IntoIterator<Item = MetaType>,
A: Allocator,
Calls register_type
for each MetaType
in the given iter
.
sourcepub fn map_into_portable<I, T>(&mut self, iter: I) -> Vec<T::Output>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
where
I: IntoIterator<Item = T>,
T: IntoPortable,
pub fn map_into_portable<I, T>(&mut self, iter: I) -> Vec<T::Output>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
where
I: IntoIterator<Item = T>,
T: IntoPortable,
A: Allocator,
Converts an iterator into a Vec of the equivalent portable representations.
Trait Implementations
sourceimpl From<Registry> for PortableRegistry
impl From<Registry> for PortableRegistry
sourceimpl PartialEq<Registry> for Registry
impl PartialEq<Registry> for Registry
impl Eq for Registry
impl StructuralEq for Registry
impl StructuralPartialEq for Registry
Auto Trait Implementations
impl RefUnwindSafe for Registry
impl Send for Registry
impl Sync for Registry
impl Unpin for Registry
impl UnwindSafe for Registry
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more