Trait ssz::Decode

source ·
pub trait Decode: Sized {
    // Required methods
    fn is_ssz_fixed_len() -> bool;
    fn from_ssz_bytes(bytes: &[u8]) -> Result<Self, DecodeError>;

    // Provided method
    fn ssz_fixed_len() -> usize { ... }
}
Expand description

Provides SSZ decoding (de-serialization) via the from_ssz_bytes(&bytes) method.

See examples/ for manual implementations or the crate root for implementations using #[derive(Decode)].

Required Methods§

source

fn is_ssz_fixed_len() -> bool

Returns true if this object has a fixed-length.

I.e., there are no variable length items in this object or any of it’s contained objects.

source

fn from_ssz_bytes(bytes: &[u8]) -> Result<Self, DecodeError>

Attempts to decode Self from bytes, returning a DecodeError on failure.

The supplied bytes must be the exact length required to decode Self, excess bytes will result in an error.

Provided Methods§

source

fn ssz_fixed_len() -> usize

The number of bytes this object occupies in the fixed-length portion of the SSZ bytes.

By default, this is set to BYTES_PER_LENGTH_OFFSET which is suitable for variable length objects, but not fixed-length objects. Fixed-length objects must return a value which represents their length.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Decode for bool

source§

impl Decode for u8

source§

impl Decode for u16

source§

impl Decode for u32

source§

impl Decode for u64

source§

impl Decode for u128

source§

impl Decode for usize

source§

impl Decode for Address

source§

impl Decode for Bloom

source§

impl Decode for Bytes

source§

impl Decode for NonZeroUsize

source§

impl Decode for U128

source§

impl Decode for U256

source§

impl Decode for [u8; 4]

source§

impl Decode for [u8; 32]

source§

impl Decode for [u8; 48]

source§

impl<A: Decode, B: Decode> Decode for (A, B)

source§

impl<A: Decode, B: Decode, C: Decode> Decode for (A, B, C)

source§

impl<A: Decode, B: Decode, C: Decode, D: Decode> Decode for (A, B, C, D)

source§

impl<A: Decode, B: Decode, C: Decode, D: Decode, E: Decode> Decode for (A, B, C, D, E)

source§

impl<A: Decode, B: Decode, C: Decode, D: Decode, E: Decode, F: Decode> Decode for (A, B, C, D, E, F)

source§

impl<A: Decode, B: Decode, C: Decode, D: Decode, E: Decode, F: Decode, G: Decode> Decode for (A, B, C, D, E, F, G)

source§

impl<A: Decode, B: Decode, C: Decode, D: Decode, E: Decode, F: Decode, G: Decode, H: Decode> Decode for (A, B, C, D, E, F, G, H)

source§

impl<A: Decode, B: Decode, C: Decode, D: Decode, E: Decode, F: Decode, G: Decode, H: Decode, I: Decode> Decode for (A, B, C, D, E, F, G, H, I)

source§

impl<A: Decode, B: Decode, C: Decode, D: Decode, E: Decode, F: Decode, G: Decode, H: Decode, I: Decode, J: Decode> Decode for (A, B, C, D, E, F, G, H, I, J)

source§

impl<A: Decode, B: Decode, C: Decode, D: Decode, E: Decode, F: Decode, G: Decode, H: Decode, I: Decode, J: Decode, K: Decode> Decode for (A, B, C, D, E, F, G, H, I, J, K)

source§

impl<A: Decode, B: Decode, C: Decode, D: Decode, E: Decode, F: Decode, G: Decode, H: Decode, I: Decode, J: Decode, K: Decode, L: Decode> Decode for (A, B, C, D, E, F, G, H, I, J, K, L)

source§

impl<K, V> Decode for BTreeMap<K, V>
where K: Decode + Ord, V: Decode,

source§

impl<T> Decode for BTreeSet<T>
where T: Decode + Ord,

source§

impl<T: Decode> Decode for Option<T>

source§

impl<T: Decode> Decode for Arc<T>

source§

impl<T: Decode> Decode for Vec<T>

source§

impl<T: Decode> Decode for SmallVec<[T; 1]>

source§

impl<T: Decode> Decode for SmallVec<[T; 2]>

source§

impl<T: Decode> Decode for SmallVec<[T; 3]>

source§

impl<T: Decode> Decode for SmallVec<[T; 4]>

source§

impl<T: Decode> Decode for SmallVec<[T; 5]>

source§

impl<T: Decode> Decode for SmallVec<[T; 6]>

source§

impl<T: Decode> Decode for SmallVec<[T; 7]>

source§

impl<T: Decode> Decode for SmallVec<[T; 8]>

source§

impl<T: Decode> Decode for SmallVec<[T; 96]>

source§

impl<const N: usize> Decode for FixedBytes<N>

Implementors§