Trait parity_scale_codec::Decode

source ·
pub trait Decode: Sized {
    // Required method
    fn decode<I: Input>(input: &mut I) -> Result<Self, Error>;

    // Provided methods
    fn decode_into<I: Input>(
        input: &mut I,
        dst: &mut MaybeUninit<Self>
    ) -> Result<DecodeFinished, Error> { ... }
    fn skip<I: Input>(input: &mut I) -> Result<(), Error> { ... }
    fn encoded_fixed_size() -> Option<usize> { ... }
}
Expand description

Trait that allows zero-copy read of value-references from slices in LE format.

Required Methods§

source

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

Attempt to deserialise the value from input.

Provided Methods§

source

fn decode_into<I: Input>( input: &mut I, dst: &mut MaybeUninit<Self> ) -> Result<DecodeFinished, Error>

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.

source

fn skip<I: Input>(input: &mut I) -> Result<(), Error>

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.

source

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Decode for bool

source§

impl Decode for f32

source§

impl Decode for f64

source§

impl Decode for i8

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl Decode for i16

source§

impl Decode for i32

source§

impl Decode for i64

source§

impl Decode for i128

source§

impl Decode for u8

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl Decode for u16

source§

impl Decode for u32

source§

impl Decode for u64

source§

impl Decode for u128

source§

impl Decode for ()

source§

impl Decode for String

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl Decode for Duration

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl Decode for NonZeroI8

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl Decode for NonZeroI16

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl Decode for NonZeroI32

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl Decode for NonZeroI64

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl Decode for NonZeroI128

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl Decode for NonZeroU8

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl Decode for NonZeroU16

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl Decode for NonZeroU32

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl Decode for NonZeroU64

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl Decode for NonZeroU128

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl<'a, T: ToOwned + ?Sized> Decode for Cow<'a, T>
where <T as ToOwned>::Owned: Decode,

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl<A0: Decode, B0: Decode, C0: Decode, D0: Decode, E0: Decode, F0: Decode, G0: Decode, H0: Decode, I0: Decode, J0: Decode, K0: Decode, L0: Decode, M0: Decode, N0: Decode, O0: Decode, P0: Decode, Q0: Decode, R0: Decode> Decode for (A0, B0, C0, D0, E0, F0, G0, H0, I0, J0, K0, L0, M0, N0, O0, P0, Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<B0: Decode, C0: Decode, D0: Decode, E0: Decode, F0: Decode, G0: Decode, H0: Decode, I0: Decode, J0: Decode, K0: Decode, L0: Decode, M0: Decode, N0: Decode, O0: Decode, P0: Decode, Q0: Decode, R0: Decode> Decode for (B0, C0, D0, E0, F0, G0, H0, I0, J0, K0, L0, M0, N0, O0, P0, Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<C0: Decode, D0: Decode, E0: Decode, F0: Decode, G0: Decode, H0: Decode, I0: Decode, J0: Decode, K0: Decode, L0: Decode, M0: Decode, N0: Decode, O0: Decode, P0: Decode, Q0: Decode, R0: Decode> Decode for (C0, D0, E0, F0, G0, H0, I0, J0, K0, L0, M0, N0, O0, P0, Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<D0: Decode, E0: Decode, F0: Decode, G0: Decode, H0: Decode, I0: Decode, J0: Decode, K0: Decode, L0: Decode, M0: Decode, N0: Decode, O0: Decode, P0: Decode, Q0: Decode, R0: Decode> Decode for (D0, E0, F0, G0, H0, I0, J0, K0, L0, M0, N0, O0, P0, Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<E0: Decode, F0: Decode, G0: Decode, H0: Decode, I0: Decode, J0: Decode, K0: Decode, L0: Decode, M0: Decode, N0: Decode, O0: Decode, P0: Decode, Q0: Decode, R0: Decode> Decode for (E0, F0, G0, H0, I0, J0, K0, L0, M0, N0, O0, P0, Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<F0: Decode, G0: Decode, H0: Decode, I0: Decode, J0: Decode, K0: Decode, L0: Decode, M0: Decode, N0: Decode, O0: Decode, P0: Decode, Q0: Decode, R0: Decode> Decode for (F0, G0, H0, I0, J0, K0, L0, M0, N0, O0, P0, Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<G0: Decode, H0: Decode, I0: Decode, J0: Decode, K0: Decode, L0: Decode, M0: Decode, N0: Decode, O0: Decode, P0: Decode, Q0: Decode, R0: Decode> Decode for (G0, H0, I0, J0, K0, L0, M0, N0, O0, P0, Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<H0: Decode, I0: Decode, J0: Decode, K0: Decode, L0: Decode, M0: Decode, N0: Decode, O0: Decode, P0: Decode, Q0: Decode, R0: Decode> Decode for (H0, I0, J0, K0, L0, M0, N0, O0, P0, Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<I0: Decode, J0: Decode, K0: Decode, L0: Decode, M0: Decode, N0: Decode, O0: Decode, P0: Decode, Q0: Decode, R0: Decode> Decode for (I0, J0, K0, L0, M0, N0, O0, P0, Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<J0: Decode, K0: Decode, L0: Decode, M0: Decode, N0: Decode, O0: Decode, P0: Decode, Q0: Decode, R0: Decode> Decode for (J0, K0, L0, M0, N0, O0, P0, Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<K0: Decode, L0: Decode, M0: Decode, N0: Decode, O0: Decode, P0: Decode, Q0: Decode, R0: Decode> Decode for (K0, L0, M0, N0, O0, P0, Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<K: Decode + Ord, V: Decode> Decode for BTreeMap<K, V>

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl<L0: Decode, M0: Decode, N0: Decode, O0: Decode, P0: Decode, Q0: Decode, R0: Decode> Decode for (L0, M0, N0, O0, P0, Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<M0: Decode, N0: Decode, O0: Decode, P0: Decode, Q0: Decode, R0: Decode> Decode for (M0, N0, O0, P0, Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<N0: Decode, O0: Decode, P0: Decode, Q0: Decode, R0: Decode> Decode for (N0, O0, P0, Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<O0: Decode, P0: Decode, Q0: Decode, R0: Decode> Decode for (O0, P0, Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<P0: Decode, Q0: Decode, R0: Decode> Decode for (P0, Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<Q0: Decode, R0: Decode> Decode for (Q0, R0)

source§

fn decode<INPUT: Input>(input: &mut INPUT) -> Result<Self, Error>

source§

impl<R0: Decode> Decode for (R0,)

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl<T> Decode for PhantomData<T>

source§

fn decode<I: Input>(_input: &mut I) -> Result<Self, Error>

source§

impl<T> Decode for Range<T>
where T: Decode,

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl<T> Decode for RangeInclusive<T>
where T: Decode,

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl<T: Decode + Ord> Decode for BinaryHeap<T>

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl<T: Decode + Ord> Decode for BTreeSet<T>

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl<T: Decode> Decode for Option<T>

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl<T: Decode> Decode for LinkedList<T>

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl<T: Decode> Decode for VecDeque<T>

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl<T: Decode> Decode for Vec<T>

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl<T: Decode, E: Decode> Decode for Result<T, E>

source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

source§

impl<T: Decode, const N: usize> Decode for [T; N]

Implementors§