parity_scale_codec

Trait 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so 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§