Struct scale_info::PortableRegistry
source · pub struct PortableRegistry {
pub types: Vec<PortableType>,
}
Expand description
A read-only registry containing types in their portable form for serialization.
Fields§
§types: Vec<PortableType>
The types contained by the PortableRegistry
.
Implementations§
source§impl PortableRegistry
impl PortableRegistry
sourcepub fn resolve(&self, id: u32) -> Option<&Type<PortableForm>>
pub fn resolve(&self, id: u32) -> Option<&Type<PortableForm>>
Returns the type definition for the given identifier, None
if no type found for that ID.
sourcepub fn types(&self) -> &[PortableType]
👎Deprecated since 2.5.0: Prefer to access the fields directly; this getter will be removed in the next major version
pub fn types(&self) -> &[PortableType]
Returns all types with their associated identifiers.
sourcepub fn retain<F>(&mut self, filter: F) -> BTreeMap<u32, u32>where
F: FnMut(u32) -> bool,
pub fn retain<F>(&mut self, filter: F) -> BTreeMap<u32, u32>where
F: FnMut(u32) -> bool,
Retains only the portable types needed to express the provided ids.
The type IDs retained are returned as key to the BTreeMap
.
The value of the map represents the new ID of that type.
Note
A given type ID can be defined by nesting type IDs, such as the case
of a TypeDef::Composite
and others. To retain a valid PortableRegistry
all the types needed to express an ID are included. Therefore, the number of
elements defined by the result equals or exceeds the number of provided IDs.
Trait Implementations§
source§impl Clone for PortableRegistry
impl Clone for PortableRegistry
source§fn clone(&self) -> PortableRegistry
fn clone(&self) -> PortableRegistry
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for PortableRegistry
impl Debug for PortableRegistry
source§impl Decode for PortableRegistry
impl Decode for PortableRegistry
source§fn decode<__CodecInputEdqy: Input>(
__codec_input_edqy: &mut __CodecInputEdqy
) -> Result<Self, Error>
fn decode<__CodecInputEdqy: Input>(
__codec_input_edqy: &mut __CodecInputEdqy
) -> Result<Self, Error>
Attempt to deserialise the value from input.
source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>
) -> Result<DecodeFinished, Error>where
I: Input,
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
source§impl<'de> Deserialize<'de> for PortableRegistry
impl<'de> Deserialize<'de> for PortableRegistry
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Encode for PortableRegistry
impl Encode for PortableRegistry
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
If possible give a hint of expected size of the encoding. Read more
source§fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy
)
fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy
)
Convert self to a slice and append it to the destination.
source§fn using_encoded<R, F: FnOnce(&[u8]) -> R>(&self, f: F) -> R
fn using_encoded<R, F: FnOnce(&[u8]) -> R>(&self, f: F) -> R
Convert self to a slice and then invoke the given closure with it.
source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Calculates the encoded size. Read more