multiversx_sc_codec

Trait TopDecode

Source
pub trait TopDecode: Sized {
    // Provided methods
    fn top_decode<I>(input: I) -> Result<Self, DecodeError>
       where I: TopDecodeInput { ... }
    fn top_decode_or_handle_err<I, H>(
        input: I,
        h: H,
    ) -> Result<Self, H::HandledErr>
       where I: TopDecodeInput,
             H: DecodeErrorHandler { ... }
}
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.

Provided Methods§

Source

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

Attempt to deserialize the value from input.

Source

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Version of top_decode that can handle errors as soon as they occur. For instance it can exit immediately and make sure that if it returns, it is a success. By not deferring error handling, this can lead to somewhat smaller bytecode.

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 TopDecode for bool

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

impl TopDecode for i8

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

impl TopDecode for i16

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

impl TopDecode for i32

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

impl TopDecode for i64

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

impl TopDecode for isize

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

impl TopDecode for u8

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

impl TopDecode for u16

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

impl TopDecode for u32

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

impl TopDecode for u64

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

impl TopDecode for usize

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

impl TopDecode for Box<str>

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

impl TopDecode for String

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

impl TopDecode for NonZeroUsize

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

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

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

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

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

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

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

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

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

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

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

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

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

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

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

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

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

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_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

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_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

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_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

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_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

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_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

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_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

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_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

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_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

impl<T> TopDecode for PhantomData<T>

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

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

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

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

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

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

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

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

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Source§

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

Source§

fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>

Implementors§