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>
impl<'a> SszDecoderBuilder<'a>
sourcepub fn new(bytes: &'a [u8]) -> Self
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.
sourcepub fn register_anonymous_variable_length_item(
&mut self,
) -> Result<(), DecodeError>
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.
sourcepub fn register_type<T: Decode>(&mut self) -> Result<(), DecodeError>
pub fn register_type<T: Decode>(&mut self) -> Result<(), DecodeError>
Declares that some type T
is the next item in bytes
.
sourcepub fn register_type_parameterized(
&mut self,
is_ssz_fixed_len: bool,
ssz_fixed_len: usize,
) -> Result<(), DecodeError>
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
.
sourcepub fn build(self) -> Result<SszDecoder<'a>, DecodeError>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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