pub struct Bitvector<const N: usize> { /* private fields */ }Expand description
SSZ Bitvector with a compile-time length of N bits.
Storage is a heap-allocated byte vector of length (N + 7) / 8. Using a
Vec avoids generic_const_exprs (still unstable) while keeping the
invariant at the type level.
Implementations§
Source§impl<const N: usize> Bitvector<N>
impl<const N: usize> Bitvector<N>
Sourcepub fn from_slice(bytes: &[u8]) -> Result<Self, DecodeError>
pub fn from_slice(bytes: &[u8]) -> Result<Self, DecodeError>
Build from a slice (must have exact length (N+7)/8).
Trait Implementations§
Source§impl<const N: usize> Decode for Bitvector<N>
impl<const N: usize> Decode for Bitvector<N>
Source§fn is_ssz_fixed_len() -> bool
fn is_ssz_fixed_len() -> bool
true iff this type is fixed-length.Source§fn ssz_fixed_len() -> usize
fn ssz_fixed_len() -> usize
Number of bytes this type occupies in the fixed-length portion of a
container encoding. Variable-length types return
BYTES_PER_LENGTH_OFFSET.Source§fn from_ssz_bytes(bytes: &[u8]) -> Result<Self, DecodeError>
fn from_ssz_bytes(bytes: &[u8]) -> Result<Self, DecodeError>
Decode a full instance from
bytes, rejecting trailing input.Source§impl<const N: usize> Encode for Bitvector<N>
impl<const N: usize> Encode for Bitvector<N>
Source§fn is_ssz_fixed_len() -> bool
fn is_ssz_fixed_len() -> bool
true iff this type is fixed-length (no variable-length fields).Source§fn ssz_fixed_len() -> usize
fn ssz_fixed_len() -> usize
Number of bytes this type occupies in the fixed-length portion of a
container encoding. For variable-length types this returns
BYTES_PER_LENGTH_OFFSET (i.e. the size of the offset slot).Source§fn ssz_bytes_len(&self) -> usize
fn ssz_bytes_len(&self) -> usize
Total size of
self when serialized.Source§fn ssz_append(&self, buf: &mut Vec<u8>)
fn ssz_append(&self, buf: &mut Vec<u8>)
Append the encoding of
self to buf.Source§fn is_basic_type() -> bool
fn is_basic_type() -> bool
true for “basic” SSZ types (uintN, bool), which pack adjacent
elements into shared 32-byte chunks for merkleization. Composite
types (containers, lists, structs) return false (the default).Source§impl<const N: usize> HashTreeRoot for Bitvector<N>
impl<const N: usize> HashTreeRoot for Bitvector<N>
impl<const N: usize> Eq for Bitvector<N>
impl<const N: usize> StructuralPartialEq for Bitvector<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for Bitvector<N>
impl<const N: usize> RefUnwindSafe for Bitvector<N>
impl<const N: usize> Send for Bitvector<N>
impl<const N: usize> Sync for Bitvector<N>
impl<const N: usize> Unpin for Bitvector<N>
impl<const N: usize> UnsafeUnpin for Bitvector<N>
impl<const N: usize> UnwindSafe for Bitvector<N>
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