Trait ssz::Encode

source ·
pub trait Encode {
    // Required methods
    fn is_ssz_fixed_len() -> bool;
    fn ssz_append(&self, buf: &mut Vec<u8>);
    fn ssz_bytes_len(&self) -> usize;

    // Provided methods
    fn ssz_fixed_len() -> usize { ... }
    fn as_ssz_bytes(&self) -> Vec<u8> { ... }
}
Expand description

Provides SSZ encoding (serialization) via the as_ssz_bytes(&self) method.

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

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 ssz_append(&self, buf: &mut Vec<u8>)

Append the encoding self to buf.

Note, variable length objects need only to append their “variable length” portion, they do not need to provide their offset.

source

fn ssz_bytes_len(&self) -> usize

Returns the size (in bytes) when self is serialized.

Returns the same value as self.as_ssz_bytes().len() but this method is significantly more efficient.

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.

source

fn as_ssz_bytes(&self) -> Vec<u8>

Returns the full-form encoding of this object.

The default implementation of this method should suffice for most cases.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Encode for bool

source§

impl Encode for u8

source§

impl Encode for u16

source§

impl Encode for u32

source§

impl Encode for u64

source§

impl Encode for u128

source§

impl Encode for usize

source§

impl Encode for Address

source§

impl Encode for Bloom

source§

impl Encode for Bytes

source§

impl Encode for NonZeroUsize

source§

impl Encode for U128

source§

impl Encode for U256

source§

impl Encode for [u8; 4]

source§

impl Encode for [u8; 32]

source§

impl Encode for [u8; 48]

source§

impl<'a, T: Encode> Encode for &'a T

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl<T: Encode> Encode for Option<T>

source§

impl<T: Encode> Encode for Arc<T>

source§

impl<T: Encode> Encode for Vec<T>

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

Implementors§