pub trait TopDecode: Sized {
    // Required method
    fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>;

    // Provided method
    fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>(
        input: I,
        c: ExitCtx,
        exit: fn(_: ExitCtx, _: DecodeError) -> !
    ) -> Self { ... }
}
Expand description

Trait that allows zero-copy read of values from an underlying API in big endian format.

‘Top’ stands for the fact that values are deserialized on their own, so we have the benefit of knowing their length. This is useful in many scnearios, such as not having to encode Vec length and others.

The opther optimization that can be done when deserializing top-level objects is using special functions from the underlying API that do some of the work for the deserializer. These include getting values directly as i64/u64 or wrapping them directly into an owned Box<u8>.

BigInt/BigUint handling is not included here, because these are API-dependent and would overly complicate the trait.

Required Methods§

source

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

Attempt to deserialize the value from input.

Provided Methods§

source

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

Version of top_decode that exits quickly in case of error. Its purpose is to create smaller implementations in cases where the application is supposed to exit directly on decode error.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl TopDecode for bool

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl TopDecode for i8

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl TopDecode for i16

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl TopDecode for i32

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl TopDecode for i64

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl TopDecode for isize

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl TopDecode for u8

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl TopDecode for u16

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl TopDecode for u32

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl TopDecode for u64

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl TopDecode for ()

source§

fn top_decode<I: TopDecodeInput>(_: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( _: I, _: ExitCtx, _: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl TopDecode for usize

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl TopDecode for Box<str>

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl TopDecode for String

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl TopDecode for NonZeroUsize

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T0> TopDecode for (T0,)
where T0: NestedDecode,

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T0, T1> TopDecode for (T0, T1)
where T0: NestedDecode, T1: NestedDecode,

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T0, T1, T2> TopDecode for (T0, T1, T2)

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T0, T1, T2, T3> TopDecode for (T0, T1, T2, T3)

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T0, T1, T2, T3, T4> TopDecode for (T0, T1, T2, T3, T4)

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T0, T1, T2, T3, T4, T5> TopDecode for (T0, T1, T2, T3, T4, T5)

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T0, T1, T2, T3, T4, T5, T6> TopDecode for (T0, T1, T2, T3, T4, T5, T6)

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7> TopDecode for (T0, T1, T2, T3, T4, T5, T6, T7)

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> TopDecode for (T0, T1, T2, T3, T4, T5, T6, T7, T8)

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> TopDecode for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> TopDecode for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> TopDecode for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> TopDecode for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> TopDecode for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> TopDecode for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> TopDecode for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T: NestedDecode> TopDecode for Option<T>

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T: NestedDecode> TopDecode for Box<[T]>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

Quick exit for any of the contained types

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

impl<T: NestedDecode, const CAP: usize> TopDecode for ArrayVec<T, CAP>

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

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

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

source§

impl<T: TopDecode> TopDecode for Box<T>

source§

fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>

source§

fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self

Implementors§