[][src]Trait ssz::Encode

pub trait Encode {
    fn is_ssz_fixed_len() -> bool;
fn ssz_append(&self, buf: &mut Vec<u8>);
fn ssz_bytes_len(&self) -> usize; fn ssz_fixed_len() -> usize { ... }
fn as_ssz_bytes(&self) -> Vec<u8> { ... } }

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

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.

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.

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.

Loading content...

Provided methods

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.

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.

Loading content...

Implementations on Foreign Types

impl Encode for u8[src]

impl Encode for u16[src]

impl Encode for u32[src]

impl Encode for u64[src]

impl Encode for usize[src]

impl<A: Encode, B: Encode> Encode for (A, B)[src]

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

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

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

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

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

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)[src]

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)[src]

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)[src]

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)[src]

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)[src]

impl<T: Encode> Encode for Option<T>[src]

The SSZ "union" type.

impl<T: Encode> Encode for Vec<T>[src]

impl Encode for bool[src]

impl Encode for NonZeroUsize[src]

impl Encode for H256[src]

impl Encode for U256[src]

impl Encode for U128[src]

impl Encode for [u8; 4][src]

impl Encode for [u8; 32][src]

Loading content...

Implementors

Loading content...