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.