Struct ssz::SszDecoderBuilder

source ·
pub struct SszDecoderBuilder<'a> { /* private fields */ }
Expand description

Builds an SszDecoder.

The purpose of this struct is to split some SSZ bytes into individual slices. The builder is then converted into a SszDecoder which decodes those values into object instances.

See SszDecoder for usage examples.

Implementations§

source§

impl<'a> SszDecoderBuilder<'a>

source

pub fn new(bytes: &'a [u8]) -> Self

Instantiate a new builder that should build a SszDecoder over the given bytes which are assumed to be the SSZ encoding of some object.

source

pub fn register_anonymous_variable_length_item( &mut self ) -> Result<(), DecodeError>

Registers a variable-length object as the next item in bytes, without specifying the actual type.

§Notes

Use of this function is generally discouraged since it cannot detect if some type changes from variable to fixed length.

Use Self::register_type wherever possible.

source

pub fn register_type<T: Decode>(&mut self) -> Result<(), DecodeError>

Declares that some type T is the next item in bytes.

source

pub fn register_type_parameterized( &mut self, is_ssz_fixed_len: bool, ssz_fixed_len: usize ) -> Result<(), DecodeError>

Declares that a type with the given parameters is the next item in bytes.

source

pub fn build(self) -> Result<SszDecoder<'a>, DecodeError>

Finalizes the builder, returning a SszDecoder that may be used to instantiate objects.

Auto Trait Implementations§

§

impl<'a> Freeze for SszDecoderBuilder<'a>

§

impl<'a> RefUnwindSafe for SszDecoderBuilder<'a>

§

impl<'a> Send for SszDecoderBuilder<'a>

§

impl<'a> Sync for SszDecoderBuilder<'a>

§

impl<'a> Unpin for SszDecoderBuilder<'a>

§

impl<'a> UnwindSafe for SszDecoderBuilder<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V