Type Alias HeaderHash
pub type HeaderHash = FixedBytes<32>;
Expand description
Hash of the block header.
Aliased Type§
struct HeaderHash(pub [u8; 32]);
Fields§
§0: [u8; 32]
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes
Implementations
§impl<const N: usize> FixedBytes<N>
impl<const N: usize> FixedBytes<N>
pub const ZERO: FixedBytes<N>
pub const ZERO: FixedBytes<N>
Array of Zero bytes.
pub const fn with_last_byte(x: u8) -> FixedBytes<N>
pub const fn with_last_byte(x: u8) -> FixedBytes<N>
Creates a new [FixedBytes
] with the last byte set to x
.
pub const fn repeat_byte(byte: u8) -> FixedBytes<N>
pub const fn repeat_byte(byte: u8) -> FixedBytes<N>
Creates a new [FixedBytes
] where all bytes are set to byte
.
pub fn random() -> FixedBytes<N>
Available on crate feature getrandom
only.
pub fn random() -> FixedBytes<N>
getrandom
only.Creates a new [FixedBytes
] with the default cryptographic random number generator.
This is rand::thread_rng
if the “rand” and “std” features are enabled, otherwise
it uses getrandom::getrandom
. Both are cryptographically secure.
pub fn try_random() -> Result<FixedBytes<N>, Error>
Available on crate feature getrandom
only.
pub fn try_random() -> Result<FixedBytes<N>, Error>
getrandom
only.Tries to create a new [FixedBytes
] with the default cryptographic random number
generator.
See random
for more details.
pub fn random_with<R>(rng: &mut R) -> FixedBytes<N>
Available on crate feature rand
only.
pub fn random_with<R>(rng: &mut R) -> FixedBytes<N>
rand
only.Creates a new [FixedBytes
] with the given random number generator.
See random
for more details.
pub fn randomize(&mut self)
Available on crate feature getrandom
only.
pub fn randomize(&mut self)
getrandom
only.Fills this [FixedBytes
] with the default cryptographic random number generator.
See random
for more details.
pub fn try_randomize(&mut self) -> Result<(), Error>
Available on crate feature getrandom
only.
pub fn try_randomize(&mut self) -> Result<(), Error>
getrandom
only.Tries to fill this [FixedBytes
] with the default cryptographic random number
generator.
See random
for more details.
pub fn randomize_with<R>(&mut self, rng: &mut R)
Available on crate feature rand
only.
pub fn randomize_with<R>(&mut self, rng: &mut R)
rand
only.Fills this [FixedBytes
] with the given random number generator.
pub const fn concat_const<const M: usize, const Z: usize>(
self,
other: FixedBytes<M>,
) -> FixedBytes<Z>
pub const fn concat_const<const M: usize, const Z: usize>( self, other: FixedBytes<M>, ) -> FixedBytes<Z>
Concatenate two FixedBytes
.
Due to constraints in the language, the user must specify the value of
the output size Z
.
§Panics
Panics if Z
is not equal to N + M
.
pub fn from_slice(src: &[u8]) -> FixedBytes<N>
pub fn from_slice(src: &[u8]) -> FixedBytes<N>
pub fn left_padding_from(value: &[u8]) -> FixedBytes<N>
pub fn left_padding_from(value: &[u8]) -> FixedBytes<N>
pub fn right_padding_from(value: &[u8]) -> FixedBytes<N>
pub fn right_padding_from(value: &[u8]) -> FixedBytes<N>
pub const fn as_slice(&self) -> &[u8] ⓘ
pub const fn as_slice(&self) -> &[u8] ⓘ
Returns a slice containing the entire array. Equivalent to &s[..]
.
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Returns a mutable slice containing the entire array. Equivalent to
&mut s[..]
.
pub fn covers(&self, other: &FixedBytes<N>) -> bool
pub fn covers(&self, other: &FixedBytes<N>) -> bool
Returns true
if all bits set in self
are also set in b
.
pub const fn const_covers(self, other: FixedBytes<N>) -> bool
pub const fn const_covers(self, other: FixedBytes<N>) -> bool
Returns true
if all bits set in self
are also set in b
.
pub const fn const_eq(&self, other: &FixedBytes<N>) -> bool
pub const fn const_eq(&self, other: &FixedBytes<N>) -> bool
Compile-time equality. NOT constant-time equality.
pub const fn const_is_zero(&self) -> bool
pub const fn const_is_zero(&self) -> bool
Returns true
if no bits are set.
pub const fn bit_and(self, rhs: FixedBytes<N>) -> FixedBytes<N>
pub const fn bit_and(self, rhs: FixedBytes<N>) -> FixedBytes<N>
Computes the bitwise AND of two FixedBytes
.
pub const fn bit_or(self, rhs: FixedBytes<N>) -> FixedBytes<N>
pub const fn bit_or(self, rhs: FixedBytes<N>) -> FixedBytes<N>
Computes the bitwise OR of two FixedBytes
.
pub const fn bit_xor(self, rhs: FixedBytes<N>) -> FixedBytes<N>
pub const fn bit_xor(self, rhs: FixedBytes<N>) -> FixedBytes<N>
Computes the bitwise XOR of two FixedBytes
.
Trait Implementations
§impl<'arbitrary, const N: usize> Arbitrary<'arbitrary> for FixedBytes<N>
impl<'arbitrary, const N: usize> Arbitrary<'arbitrary> for FixedBytes<N>
§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<FixedBytes<N>, Error>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<FixedBytes<N>, Error>
Self
from the given unstructured data. Read more§fn arbitrary_take_rest(
u: Unstructured<'arbitrary>,
) -> Result<FixedBytes<N>, Error>
fn arbitrary_take_rest( u: Unstructured<'arbitrary>, ) -> Result<FixedBytes<N>, Error>
Self
from the entirety of the given
unstructured data. Read more§impl<const N: usize> Arbitrary for FixedBytes<N>
impl<const N: usize> Arbitrary for FixedBytes<N>
§type Parameters = <[u8; N] as Arbitrary>::Parameters
type Parameters = <[u8; N] as Arbitrary>::Parameters
arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.§type Strategy = Map<<[u8; N] as Arbitrary>::Strategy, fn(_: [u8; N]) -> FixedBytes<N>>
type Strategy = Map<<[u8; N] as Arbitrary>::Strategy, fn(_: [u8; N]) -> FixedBytes<N>>
Strategy
used to generate values of type Self
.§fn arbitrary_with(
_top: <FixedBytes<N> as Arbitrary>::Parameters,
) -> <FixedBytes<N> as Arbitrary>::Strategy
fn arbitrary_with( _top: <FixedBytes<N> as Arbitrary>::Parameters, ) -> <FixedBytes<N> as Arbitrary>::Strategy
§impl<const N: usize> BitAndAssign for FixedBytes<N>
impl<const N: usize> BitAndAssign for FixedBytes<N>
§fn bitand_assign(&mut self, rhs: FixedBytes<N>)
fn bitand_assign(&mut self, rhs: FixedBytes<N>)
&=
operation. Read more§impl<const N: usize> BitOrAssign for FixedBytes<N>
impl<const N: usize> BitOrAssign for FixedBytes<N>
§fn bitor_assign(&mut self, rhs: FixedBytes<N>)
fn bitor_assign(&mut self, rhs: FixedBytes<N>)
|=
operation. Read more§impl<const N: usize> BitXorAssign for FixedBytes<N>
impl<const N: usize> BitXorAssign for FixedBytes<N>
§fn bitxor_assign(&mut self, rhs: FixedBytes<N>)
fn bitxor_assign(&mut self, rhs: FixedBytes<N>)
^=
operation. Read more§impl<const N: usize> BorrowMut<[u8]> for FixedBytes<N>
impl<const N: usize> BorrowMut<[u8]> for FixedBytes<N>
§fn borrow_mut(&mut self) -> &mut [u8] ⓘ
fn borrow_mut(&mut self) -> &mut [u8] ⓘ
§impl<const N: usize> BorrowMut<[u8; N]> for FixedBytes<N>
impl<const N: usize> BorrowMut<[u8; N]> for FixedBytes<N>
§fn borrow_mut(&mut self) -> &mut [u8; N]
fn borrow_mut(&mut self) -> &mut [u8; N]
§impl<const N: usize> Compact for FixedBytes<N>
impl<const N: usize> Compact for FixedBytes<N>
§fn to_compact<B>(&self, buf: &mut B) -> usize
fn to_compact<B>(&self, buf: &mut B) -> usize
§fn from_compact(buf: &[u8], len: usize) -> (FixedBytes<N>, &[u8])
fn from_compact(buf: &[u8], len: usize) -> (FixedBytes<N>, &[u8])
buf
with its internal cursor
advanced (eg..advance(len)
). Read more§fn specialized_to_compact<B>(&self, buf: &mut B) -> usize
fn specialized_to_compact<B>(&self, buf: &mut B) -> usize
§fn specialized_from_compact(buf: &[u8], len: usize) -> (Self, &[u8])
fn specialized_from_compact(buf: &[u8], len: usize) -> (Self, &[u8])
§impl Compress for FixedBytes<32>
impl Compress for FixedBytes<32>
§type Compressed = Vec<u8>
type Compressed = Vec<u8>
§fn uncompressable_ref(&self) -> Option<&[u8]>
fn uncompressable_ref(&self) -> Option<&[u8]>
Some(self.as_ref())
§fn compress_to_buf<B>(&self, buf: &mut B)
fn compress_to_buf<B>(&self, buf: &mut B)
§fn compress(self) -> Self::Compressed
fn compress(self) -> Self::Compressed
§impl Decode for FixedBytes<32>
impl Decode for FixedBytes<32>
§fn decode(value: &[u8]) -> Result<FixedBytes<32>, DatabaseError>
fn decode(value: &[u8]) -> Result<FixedBytes<32>, DatabaseError>
§fn decode_owned(value: Vec<u8>) -> Result<Self, DatabaseError>
fn decode_owned(value: Vec<u8>) -> Result<Self, DatabaseError>
§impl<const N: usize> Decode for FixedBytes<N>
impl<const N: usize> Decode for FixedBytes<N>
§fn is_ssz_fixed_len() -> bool
fn is_ssz_fixed_len() -> bool
true
if this object has a fixed-length. Read more§fn ssz_fixed_len() -> usize
fn ssz_fixed_len() -> usize
§fn from_ssz_bytes(bytes: &[u8]) -> Result<FixedBytes<N>, DecodeError>
fn from_ssz_bytes(bytes: &[u8]) -> Result<FixedBytes<N>, DecodeError>
§impl Decompress for FixedBytes<32>
impl Decompress for FixedBytes<32>
§fn decompress(value: &[u8]) -> Result<FixedBytes<32>, DatabaseError>
fn decompress(value: &[u8]) -> Result<FixedBytes<32>, DatabaseError>
§fn decompress_owned(value: Vec<u8>) -> Result<Self, DatabaseError>
fn decompress_owned(value: Vec<u8>) -> Result<Self, DatabaseError>
§impl<'de, const N: usize> Deserialize<'de> for FixedBytes<N>
impl<'de, const N: usize> Deserialize<'de> for FixedBytes<N>
§fn deserialize<D>(
deserializer: D,
) -> Result<FixedBytes<N>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<FixedBytes<N>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl<const N: usize> Encode for FixedBytes<N>
impl<const N: usize> Encode for FixedBytes<N>
§fn is_ssz_fixed_len() -> bool
fn is_ssz_fixed_len() -> bool
true
if this object has a fixed-length. Read more§fn ssz_bytes_len(&self) -> usize
fn ssz_bytes_len(&self) -> usize
self
is serialized. Read more§fn ssz_fixed_len() -> usize
fn ssz_fixed_len() -> usize
§fn ssz_append(&self, buf: &mut Vec<u8>)
fn ssz_append(&self, buf: &mut Vec<u8>)
§impl InMemorySize for FixedBytes<32>
impl InMemorySize for FixedBytes<32>
§impl<const N: usize> IntoIterator for FixedBytes<N>
impl<const N: usize> IntoIterator for FixedBytes<N>
§impl<const N: usize> Ord for FixedBytes<N>
impl<const N: usize> Ord for FixedBytes<N>
§impl<const N: usize> PartialOrd<&[u8]> for FixedBytes<N>
impl<const N: usize> PartialOrd<&[u8]> for FixedBytes<N>
§impl<const N: usize> PartialOrd<[u8]> for FixedBytes<N>
impl<const N: usize> PartialOrd<[u8]> for FixedBytes<N>
§impl<const N: usize> PartialOrd for FixedBytes<N>
impl<const N: usize> PartialOrd for FixedBytes<N>
§impl<const N: usize> Serialize for FixedBytes<N>
impl<const N: usize> Serialize for FixedBytes<N>
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
§impl<const N: usize> SolValue for FixedBytes<N>where
ByteCount<N>: SupportedFixedBytes,
impl<const N: usize> SolValue for FixedBytes<N>where
ByteCount<N>: SupportedFixedBytes,
§fn sol_type_name(&self) -> Cow<'static, str>
fn sol_type_name(&self) -> Cow<'static, str>
sol_name
instead§fn tokenize(&self) -> <Self::SolType as SolType>::Token<'_>
fn tokenize(&self) -> <Self::SolType as SolType>::Token<'_>
§fn detokenize(token: <Self::SolType as SolType>::Token<'_>) -> Selfwhere
Self: From<<Self::SolType as SolType>::RustType>,
fn detokenize(token: <Self::SolType as SolType>::Token<'_>) -> Selfwhere
Self: From<<Self::SolType as SolType>::RustType>,
§fn abi_encoded_size(&self) -> usize
fn abi_encoded_size(&self) -> usize
§fn eip712_data_word(&self) -> FixedBytes<32>
fn eip712_data_word(&self) -> FixedBytes<32>
encodeData
rules, and hash it
if necessary. Read more§fn abi_encode_packed_to(&self, out: &mut Vec<u8>)
fn abi_encode_packed_to(&self, out: &mut Vec<u8>)
§fn abi_encode_sequence(&self) -> Vec<u8> ⓘwhere
<Self::SolType as SolType>::Token<'a>: for<'a> TokenSeq<'a>,
fn abi_encode_sequence(&self) -> Vec<u8> ⓘwhere
<Self::SolType as SolType>::Token<'a>: for<'a> TokenSeq<'a>,
§fn abi_encode_params(&self) -> Vec<u8> ⓘwhere
<Self::SolType as SolType>::Token<'a>: for<'a> TokenSeq<'a>,
fn abi_encode_params(&self) -> Vec<u8> ⓘwhere
<Self::SolType as SolType>::Token<'a>: for<'a> TokenSeq<'a>,
§fn abi_decode(data: &[u8], validate: bool) -> Result<Self, Error>where
Self: From<<Self::SolType as SolType>::RustType>,
fn abi_decode(data: &[u8], validate: bool) -> Result<Self, Error>where
Self: From<<Self::SolType as SolType>::RustType>,
§impl<const N: usize> TryFrom<&[u8]> for FixedBytes<N>
Tries to create a FixedBytes<N>
by copying from a slice &[u8]
. Succeeds
if slice.len() == N
.
impl<const N: usize> TryFrom<&[u8]> for FixedBytes<N>
Tries to create a FixedBytes<N>
by copying from a slice &[u8]
. Succeeds
if slice.len() == N
.
§impl<const N: usize> TryFrom<&mut [u8]> for FixedBytes<N>
Tries to create a FixedBytes<N>
by copying from a mutable slice &mut [u8]
. Succeeds if slice.len() == N
.
impl<const N: usize> TryFrom<&mut [u8]> for FixedBytes<N>
Tries to create a FixedBytes<N>
by copying from a mutable slice &mut [u8]
. Succeeds if slice.len() == N
.