pub struct ContainerDecoder<'a> { /* private fields */ }Expand description
Helper for decoding containers with mixed fixed/variable fields.
Parses the fixed part to extract field slices and variable-field offsets.
Implementations§
Source§impl<'a> ContainerDecoder<'a>
impl<'a> ContainerDecoder<'a>
Sourcepub fn new(bytes: &'a [u8], fixed_part_len: usize) -> Result<Self, DecodeError>
pub fn new(bytes: &'a [u8], fixed_part_len: usize) -> Result<Self, DecodeError>
Create a new decoder. fixed_part_len is the expected total size of the
fixed portion (sum of fixed field sizes + 4 bytes per variable field).
Sourcepub fn decode_fixed<T: SszDecode>(&mut self) -> Result<T, DecodeError>
pub fn decode_fixed<T: SszDecode>(&mut self) -> Result<T, DecodeError>
Decode a fixed-size field at the current cursor position.
Sourcepub fn read_variable_offset(&mut self) -> Result<(), DecodeError>
pub fn read_variable_offset(&mut self) -> Result<(), DecodeError>
Read a variable-field offset at the current cursor position. Call this for each variable field in order during the fixed-part pass.
Sourcepub fn decode_variable<T: SszDecode>(&mut self) -> Result<T, DecodeError>
pub fn decode_variable<T: SszDecode>(&mut self) -> Result<T, DecodeError>
Decode the next variable-length field. Must be called after all fixed-part reads (decode_fixed / read_variable_offset) are done.
Sourcepub fn finish_fixed(self) -> Result<(), DecodeError>
pub fn finish_fixed(self) -> Result<(), DecodeError>
Verify there are no unconsumed bytes (for all-fixed containers).
Auto Trait Implementations§
impl<'a> Freeze for ContainerDecoder<'a>
impl<'a> RefUnwindSafe for ContainerDecoder<'a>
impl<'a> Send for ContainerDecoder<'a>
impl<'a> Sync for ContainerDecoder<'a>
impl<'a> Unpin for ContainerDecoder<'a>
impl<'a> UnsafeUnpin for ContainerDecoder<'a>
impl<'a> UnwindSafe for ContainerDecoder<'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
Mutably borrows from an owned value. Read more