pub trait Encode {
// Required methods
fn is_ssz_fixed_len() -> bool;
fn ssz_bytes_len(&self) -> usize;
fn ssz_append(&self, buf: &mut Vec<u8>);
// Provided methods
fn ssz_fixed_len() -> usize { ... }
fn is_basic_type() -> bool { ... }
fn as_ssz_bytes(&self) -> Vec<u8> ⓘ { ... }
}Expand description
SSZ encoding trait.
ssz_append is the primary primitive: every other method delegates to it.
Required Methods§
Sourcefn is_ssz_fixed_len() -> bool
fn is_ssz_fixed_len() -> bool
true iff this type is fixed-length (no variable-length fields).
Sourcefn ssz_bytes_len(&self) -> usize
fn ssz_bytes_len(&self) -> usize
Total size of self when serialized.
Sourcefn ssz_append(&self, buf: &mut Vec<u8>)
fn ssz_append(&self, buf: &mut Vec<u8>)
Append the encoding of self to buf.
Provided Methods§
Sourcefn ssz_fixed_len() -> usize
fn ssz_fixed_len() -> usize
Number of bytes this type occupies in the fixed-length portion of a
container encoding. For variable-length types this returns
BYTES_PER_LENGTH_OFFSET (i.e. the size of the offset slot).
Sourcefn is_basic_type() -> bool
fn is_basic_type() -> bool
true for “basic” SSZ types (uintN, bool), which pack adjacent
elements into shared 32-byte chunks for merkleization. Composite
types (containers, lists, structs) return false (the default).
Sourcefn as_ssz_bytes(&self) -> Vec<u8> ⓘ
fn as_ssz_bytes(&self) -> Vec<u8> ⓘ
Serialize into a fresh Vec<u8> allocated through the global allocator.
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.