pub trait TopDecode: Sized {
    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§

Attempt to deserialize the value from input.

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.

Implementations on Foreign Types§

Implementors§