multiversx_sc_snippets::imports

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 as DecodeErrorHandler>::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 as DecodeErrorHandler>::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§

impl TopDecode for i8

Source§

impl TopDecode for i16

Source§

impl TopDecode for i32

Source§

impl TopDecode for i64

Source§

impl TopDecode for isize

Source§

impl TopDecode for u8

Source§

impl TopDecode for u16

Source§

impl TopDecode for u32

Source§

impl TopDecode for u64

Source§

impl TopDecode for usize

Source§

impl TopDecode for NonZero<usize>

Source§

impl TopDecode for HeapAddress

Source§

impl TopDecode for HeapH256

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

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§

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§

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§

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§

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§

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§

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§

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

Source§

impl<T> TopDecode for PhantomData<T>

Source§

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

Implementors§

Source§

impl TopDecode for EsdtLocalRole

Source§

impl TopDecode for EsdtTokenType

Source§

impl TopDecode for MessageHashType

Source§

impl TopDecode for OperationCompletionStatus

Source§

impl TopDecode for Sign

Source§

impl TopDecode for Address

Source§

impl TopDecode for Bech32Address

Source§

impl TopDecode for Box<str>

Source§

impl TopDecode for BoxedBytes

Source§

impl TopDecode for CodeMetadata

Source§

impl TopDecode for Empty

Source§

impl TopDecode for H256

Source§

impl TopDecode for multiversx_sc_snippets::imports::RustBigInt

Source§

impl TopDecode for multiversx_sc_snippets::imports::RustBigUint

Source§

impl TopDecode for String

Source§

impl<E, const CAPACITY: usize> TopDecode for SparseArray<E, CAPACITY>
where E: ErrorApi,

Source§

impl<M> TopDecode for EgldOrMultiEsdtPayment<M>
where M: ManagedTypeApi,

Source§

impl<M> TopDecode for TokenMapperState<M>
where M: ManagedTypeApi,

Source§

impl<M> TopDecode for BigFloat<M>
where M: ManagedTypeApi,

Source§

impl<M> TopDecode for multiversx_sc_snippets::imports::BigInt<M>
where M: ManagedTypeApi,

Source§

impl<M> TopDecode for multiversx_sc_snippets::imports::BigUint<M>
where M: ManagedTypeApi,

Source§

impl<M> TopDecode for CallbackClosureForDeser<M>

Source§

impl<M> TopDecode for EgldOrEsdtTokenIdentifier<M>
where M: ManagedTypeApi,

Source§

impl<M> TopDecode for EgldOrEsdtTokenPayment<M>
where M: ManagedTypeApi,

Source§

impl<M> TopDecode for EsdtTokenData<M>
where M: ManagedTypeApi,

Source§

impl<M> TopDecode for EsdtTokenPayment<M>
where M: ManagedTypeApi,

Source§

impl<M> TopDecode for ManagedAddress<M>
where M: ManagedTypeApi,

Source§

impl<M> TopDecode for ManagedArgBuffer<M>
where M: ManagedTypeApi,

Source§

impl<M> TopDecode for ManagedBuffer<M>
where M: ManagedTypeApi,

Source§

impl<M> TopDecode for ManagedDecimal<M, usize>
where M: ManagedTypeApi,

Source§

impl<M> TopDecode for ManagedDecimalSigned<M, usize>
where M: ManagedTypeApi,

Source§

impl<M> TopDecode for TokenIdentifier<M>
where M: ManagedTypeApi,

Source§

impl<M, T> TopDecode for ManagedOption<M, T>

Source§

impl<M, T> TopDecode for ManagedVec<M, T>

Source§

impl<M, const DECIMALS: usize> TopDecode for ManagedDecimal<M, ConstDecimals<DECIMALS>>
where M: ManagedTypeApi,

Source§

impl<M, const DECIMALS: usize> TopDecode for ManagedDecimalSigned<M, ConstDecimals<DECIMALS>>
where M: ManagedTypeApi,

Source§

impl<M, const N: usize> TopDecode for ManagedByteArray<M, N>
where M: ManagedTypeApi,

Source§

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

Source§

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

Source§

impl<T> TopDecode for LinkedListNode<T>

Source§

impl<T> TopDecode for OrderedBinaryTreeNode<T>

Source§

impl<T> TopDecode for Queue<T>
where T: NestedDecode,

Deserializes like a Vec.

Source§

impl<T> TopDecode for SingleValue<T>
where T: TopDecode,

Source§

impl<T> TopDecode for Vec<T>
where T: NestedDecode,

Source§

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