Trait gclient::ext::sp_runtime::codec::Decode
pub trait Decode: Sized {
// Required method
fn decode<I>(input: &mut I) -> Result<Self, Error>
where I: Input;
// Provided methods
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>
where I: Input { ... }
fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input { ... }
fn encoded_fixed_size() -> Option<usize> { ... }
}
Expand description
Trait that allows zero-copy read of value-references from slices in LE format.
Required Methods§
Provided Methods§
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.
The default implementation will just call Decode::decode
.
§Safety
If this function returns Ok
then dst
must be properly initialized.
This is enforced by requiring the implementation to return a DecodeFinished
which can only be created by calling DecodeFinished::assert_decoding_finished
which is unsafe
.
fn skip<I>(input: &mut I) -> Result<(), Error>where
I: Input,
fn skip<I>(input: &mut I) -> Result<(), Error>where
I: Input,
Attempt to skip the encoded value from input.
The default implementation of this function is just calling Decode::decode
.
When possible, an implementation should provide a specialized implementation.
fn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
Returns the fixed encoded size of the type.
If it returns Some(size)
then all possible values of this
type have the given size (in bytes) when encoded.
NOTE: A type with a fixed encoded size may return None
.