#[non_exhaustive]pub struct SimpleCoder;
Expand description
Simple coder that only uses the last 31 bytes of each blob. This is the
default coder for the SidecarBuilder
.
§Note
Because this coder sacrifices around 3% of total sidecar space, we do not recommend its use in production. It is provided for convenience and non-prod environments.
§Behavior
This coder encodes data as follows:
- The first byte of every 32-byte word is empty.
- Data is pre-pended with a 64-bit big-endian length prefix, which is right padded with zeros to form a complete word.
- The rest of the data is packed into the remaining 31 bytes of each word.
- If the data is not a multiple of 31 bytes, the last word is right-padded with zeros.
This means that the following regions cannot be used to store data, and are considered “wasted”:
- The first byte of every 32-byte word.
- The right padding on the header word containing the data length.
- Any right padding on the last word for each piece of data.
Trait Implementations§
source§impl Clone for SimpleCoder
impl Clone for SimpleCoder
source§fn clone(&self) -> SimpleCoder
fn clone(&self) -> SimpleCoder
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for SimpleCoder
impl Debug for SimpleCoder
source§impl Default for SimpleCoder
impl Default for SimpleCoder
source§fn default() -> SimpleCoder
fn default() -> SimpleCoder
Returns the “default value” for a type. Read more
source§impl SidecarCoder for SimpleCoder
impl SidecarCoder for SimpleCoder
source§fn finish(self, _builder: &mut PartialSidecar)
fn finish(self, _builder: &mut PartialSidecar)
No-op
source§fn required_fe(&self, data: &[u8]) -> usize
fn required_fe(&self, data: &[u8]) -> usize
Calculate the number of field elements required to store the given
data.
source§fn code(&mut self, builder: &mut PartialSidecar, data: &[u8])
fn code(&mut self, builder: &mut PartialSidecar, data: &[u8])
Code a slice of data into the builder.
source§fn decode_all(
&mut self,
blobs: &[FixedBytes<alloy_eips::::eip4844::Blob::{constant#0}>],
) -> Option<Vec<Vec<u8>>>
fn decode_all( &mut self, blobs: &[FixedBytes<alloy_eips::::eip4844::Blob::{constant#0}>], ) -> Option<Vec<Vec<u8>>>
Decode all slices of data from the blobs.
impl Copy for SimpleCoder
Auto Trait Implementations§
impl Freeze for SimpleCoder
impl RefUnwindSafe for SimpleCoder
impl Send for SimpleCoder
impl Sync for SimpleCoder
impl Unpin for SimpleCoder
impl UnwindSafe for SimpleCoder
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)