pub struct PortableRegistryBuilder { /* private fields */ }
Expand description
Construct a PortableRegistry
.
Guarantees that the resulting PortableRegistry
has the list of types in the correct order,
since downstream libs assume that a u32
type id corresponds to the index of the type
definition type table.
Implementations§
source§impl PortableRegistryBuilder
impl PortableRegistryBuilder
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new PortableRegistryBuilder
.
sourcepub fn register_type(&mut self, ty: Type<PortableForm>) -> u32
pub fn register_type(&mut self, ty: Type<PortableForm>) -> u32
Register a type, returning the assigned ID.
If the type is already registered it will return the existing ID.
sourcepub fn next_type_id(&self) -> u32
pub fn next_type_id(&self) -> u32
Returns the type id that would be assigned to a newly registered type.
sourcepub fn get(&self, id: u32) -> Option<&Type<PortableForm>>
pub fn get(&self, id: u32) -> Option<&Type<PortableForm>>
Returns a reference to the type registered at the given ID (if any).
sourcepub fn finish(&self) -> PortableRegistry
pub fn finish(&self) -> PortableRegistry
Finalize and return a valid PortableRegistry
instance.
Trait Implementations§
source§impl Debug for PortableRegistryBuilder
impl Debug for PortableRegistryBuilder
source§impl Default for PortableRegistryBuilder
impl Default for PortableRegistryBuilder
source§fn default() -> PortableRegistryBuilder
fn default() -> PortableRegistryBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PortableRegistryBuilder
impl RefUnwindSafe for PortableRegistryBuilder
impl Send for PortableRegistryBuilder
impl Sync for PortableRegistryBuilder
impl Unpin for PortableRegistryBuilder
impl UnwindSafe for PortableRegistryBuilder
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
Mutably borrows from an owned value. Read more