pub struct B256(/* private fields */);Expand description
Fixed-width 256-bit hash bytes.
All equality for this type is constant-time because hashes appear in cryptographic verification paths.
The Hash implementation is for ordinary map/set use. Do not rely on
hash-map lookup timing for secret or side-channel-sensitive verification
paths; use explicit indexed structures or constant-time scans there.
Implementations§
Source§impl B256
impl B256
Sourcepub fn encoded_rlp_len(self) -> Result<usize, PrimitiveRlpError>
pub fn encoded_rlp_len(self) -> Result<usize, PrimitiveRlpError>
Returns the canonical RLP encoded length.
This is currently infallible for the fixed 32-byte hash payload but
keeps the same Result shape as the other primitive bridge helpers.
Sourcepub fn encode_rlp(self, output: &mut [u8]) -> Result<usize, PrimitiveRlpError>
pub fn encode_rlp(self, output: &mut [u8]) -> Result<usize, PrimitiveRlpError>
Canonically encodes this hash as a fixed-width scalar.
Returns the number of bytes written. output is not modified unless
this function returns Ok.
Sourcepub fn try_from_rlp(
input: &[u8],
limits: DecodeLimits,
) -> Result<Self, PrimitiveRlpError>
pub fn try_from_rlp( input: &[u8], limits: DecodeLimits, ) -> Result<Self, PrimitiveRlpError>
Decodes exactly one fixed-width hash scalar.
Trait Implementations§
impl Copy for B256
impl Eq for B256
Source§impl RlpDecode for B256
impl RlpDecode for B256
Source§type Error = PrimitiveRlpError
type Error = PrimitiveRlpError
Error returned by this decoder.
Source§fn decode_rlp(input: &[u8], limits: DecodeLimits) -> Result<Self, Self::Error>
fn decode_rlp(input: &[u8], limits: DecodeLimits) -> Result<Self, Self::Error>
Decodes exactly one canonical RLP item from
input.Auto Trait Implementations§
impl Freeze for B256
impl RefUnwindSafe for B256
impl Send for B256
impl Sync for B256
impl Unpin for B256
impl UnsafeUnpin for B256
impl UnwindSafe for B256
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