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