Struct alloy_primitives::FixedBytes
source · #[repr(transparent)]pub struct FixedBytes<const N: usize>(pub [u8; N]);
Expand description
A byte array of fixed length ([u8; N]
).
This type allows us to more tightly control serialization, deserialization. rlp encoding, decoding, and other type-level attributes for fixed-length byte arrays.
Users looking to prevent type-confusion between byte arrays of different
lengths should use the wrap_fixed_bytes!
macro
to create a new fixed-length byte array type.
Tuple Fields§
§0: [u8; N]
Implementations§
source§impl<const N: usize> FixedBytes<N>
impl<const N: usize> FixedBytes<N>
sourcepub const fn new(bytes: [u8; N]) -> Self
pub const fn new(bytes: [u8; N]) -> Self
Wraps the given byte array in FixedBytes
.
sourcepub const fn with_last_byte(x: u8) -> Self
pub const fn with_last_byte(x: u8) -> Self
Creates a new FixedBytes
with the last byte set to x
.
sourcepub const fn repeat_byte(byte: u8) -> Self
pub const fn repeat_byte(byte: u8) -> Self
Creates a new FixedBytes
where all bytes are set to byte
.
sourcepub 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
.
sourcepub fn from_slice(src: &[u8]) -> Self
pub fn from_slice(src: &[u8]) -> Self
Create a new FixedBytes
from the given slice src
.
For a fallible version, use the TryFrom<&[u8]>
implementation.
§Note
The given bytes are interpreted in big endian order.
§Panics
If the length of src
and the number of bytes in Self
do not match.
sourcepub fn left_padding_from(value: &[u8]) -> Self
pub fn left_padding_from(value: &[u8]) -> Self
Create a new FixedBytes
from the given slice src
, left-padding it
with zeroes if necessary.
§Note
The given bytes are interpreted in big endian order.
§Panics
Panics if src.len() > N
.
sourcepub fn right_padding_from(value: &[u8]) -> Self
pub fn right_padding_from(value: &[u8]) -> Self
Create a new FixedBytes
from the given slice src
, right-padding it
with zeroes if necessary.
§Note
The given bytes are interpreted in big endian order.
§Panics
Panics if src.len() > N
.
sourcepub const fn as_slice(&self) -> &[u8] ⓘ
pub const fn as_slice(&self) -> &[u8] ⓘ
Returns a slice containing the entire array. Equivalent to &s[..]
.
sourcepub 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[..]
.
sourcepub fn covers(&self, other: &Self) -> bool
pub fn covers(&self, other: &Self) -> bool
Returns true
if all bits set in self
are also set in b
.
sourcepub const fn const_covers(self, other: Self) -> bool
pub const fn const_covers(self, other: Self) -> bool
Returns true
if all bits set in self
are also set in b
.
sourcepub const fn const_eq(&self, other: &Self) -> bool
pub const fn const_eq(&self, other: &Self) -> bool
Compile-time equality. NOT constant-time equality.
sourcepub const fn const_is_zero(&self) -> bool
pub const fn const_is_zero(&self) -> bool
Returns true
if no bits are set.
Methods from Deref<Target = [u8; N]>§
1.57.0 · sourcepub fn as_slice(&self) -> &[T]
pub fn as_slice(&self) -> &[T]
Returns a slice containing the entire array. Equivalent to &s[..]
.
1.57.0 · sourcepub fn as_mut_slice(&mut self) -> &mut [T]
pub fn as_mut_slice(&mut self) -> &mut [T]
Returns a mutable slice containing the entire array. Equivalent to
&mut s[..]
.
1.77.0 · sourcepub fn each_ref(&self) -> [&T; N]
pub fn each_ref(&self) -> [&T; N]
Borrows each element and returns an array of references with the same
size as self
.
§Example
let floats = [3.1, 2.7, -1.0];
let float_refs: [&f64; 3] = floats.each_ref();
assert_eq!(float_refs, [&3.1, &2.7, &-1.0]);
This method is particularly useful if combined with other methods, like
map
. This way, you can avoid moving the original
array if its elements are not Copy
.
let strings = ["Ferris".to_string(), "♥".to_string(), "Rust".to_string()];
let is_ascii = strings.each_ref().map(|s| s.is_ascii());
assert_eq!(is_ascii, [true, false, true]);
// We can still access the original array: it has not been moved.
assert_eq!(strings.len(), 3);
1.77.0 · sourcepub fn each_mut(&mut self) -> [&mut T; N]
pub fn each_mut(&mut self) -> [&mut T; N]
Borrows each element mutably and returns an array of mutable references
with the same size as self
.
§Example
let mut floats = [3.1, 2.7, -1.0];
let float_refs: [&mut f64; 3] = floats.each_mut();
*float_refs[0] = 0.0;
assert_eq!(float_refs, [&mut 0.0, &mut 2.7, &mut -1.0]);
assert_eq!(floats, [0.0, 2.7, -1.0]);
sourcepub fn split_array_ref<const M: usize>(&self) -> (&[T; M], &[T])
🔬This is a nightly-only experimental API. (split_array
)
pub fn split_array_ref<const M: usize>(&self) -> (&[T; M], &[T])
split_array
)Divides one array reference into two at an index.
The first will contain all indices from [0, M)
(excluding
the index M
itself) and the second will contain all
indices from [M, N)
(excluding the index N
itself).
§Panics
Panics if M > N
.
§Examples
#![feature(split_array)]
let v = [1, 2, 3, 4, 5, 6];
{
let (left, right) = v.split_array_ref::<0>();
assert_eq!(left, &[]);
assert_eq!(right, &[1, 2, 3, 4, 5, 6]);
}
{
let (left, right) = v.split_array_ref::<2>();
assert_eq!(left, &[1, 2]);
assert_eq!(right, &[3, 4, 5, 6]);
}
{
let (left, right) = v.split_array_ref::<6>();
assert_eq!(left, &[1, 2, 3, 4, 5, 6]);
assert_eq!(right, &[]);
}
sourcepub fn split_array_mut<const M: usize>(&mut self) -> (&mut [T; M], &mut [T])
🔬This is a nightly-only experimental API. (split_array
)
pub fn split_array_mut<const M: usize>(&mut self) -> (&mut [T; M], &mut [T])
split_array
)Divides one mutable array reference into two at an index.
The first will contain all indices from [0, M)
(excluding
the index M
itself) and the second will contain all
indices from [M, N)
(excluding the index N
itself).
§Panics
Panics if M > N
.
§Examples
#![feature(split_array)]
let mut v = [1, 0, 3, 0, 5, 6];
let (left, right) = v.split_array_mut::<2>();
assert_eq!(left, &mut [1, 0][..]);
assert_eq!(right, &mut [3, 0, 5, 6]);
left[1] = 2;
right[1] = 4;
assert_eq!(v, [1, 2, 3, 4, 5, 6]);
sourcepub fn rsplit_array_ref<const M: usize>(&self) -> (&[T], &[T; M])
🔬This is a nightly-only experimental API. (split_array
)
pub fn rsplit_array_ref<const M: usize>(&self) -> (&[T], &[T; M])
split_array
)Divides one array reference into two at an index from the end.
The first will contain all indices from [0, N - M)
(excluding
the index N - M
itself) and the second will contain all
indices from [N - M, N)
(excluding the index N
itself).
§Panics
Panics if M > N
.
§Examples
#![feature(split_array)]
let v = [1, 2, 3, 4, 5, 6];
{
let (left, right) = v.rsplit_array_ref::<0>();
assert_eq!(left, &[1, 2, 3, 4, 5, 6]);
assert_eq!(right, &[]);
}
{
let (left, right) = v.rsplit_array_ref::<2>();
assert_eq!(left, &[1, 2, 3, 4]);
assert_eq!(right, &[5, 6]);
}
{
let (left, right) = v.rsplit_array_ref::<6>();
assert_eq!(left, &[]);
assert_eq!(right, &[1, 2, 3, 4, 5, 6]);
}
sourcepub fn rsplit_array_mut<const M: usize>(&mut self) -> (&mut [T], &mut [T; M])
🔬This is a nightly-only experimental API. (split_array
)
pub fn rsplit_array_mut<const M: usize>(&mut self) -> (&mut [T], &mut [T; M])
split_array
)Divides one mutable array reference into two at an index from the end.
The first will contain all indices from [0, N - M)
(excluding
the index N - M
itself) and the second will contain all
indices from [N - M, N)
(excluding the index N
itself).
§Panics
Panics if M > N
.
§Examples
#![feature(split_array)]
let mut v = [1, 0, 3, 0, 5, 6];
let (left, right) = v.rsplit_array_mut::<4>();
assert_eq!(left, &mut [1, 0]);
assert_eq!(right, &mut [3, 0, 5, 6][..]);
left[1] = 2;
right[1] = 4;
assert_eq!(v, [1, 2, 3, 4, 5, 6]);
sourcepub fn as_ascii(&self) -> Option<&[AsciiChar; N]>
🔬This is a nightly-only experimental API. (ascii_char
)
pub fn as_ascii(&self) -> Option<&[AsciiChar; N]>
ascii_char
)Converts this array of bytes into a array of ASCII characters,
or returns None
if any of the characters is non-ASCII.
§Examples
#![feature(ascii_char)]
#![feature(const_option)]
const HEX_DIGITS: [std::ascii::Char; 16] =
*b"0123456789abcdef".as_ascii().unwrap();
assert_eq!(HEX_DIGITS[1].as_str(), "1");
assert_eq!(HEX_DIGITS[10].as_str(), "a");
sourcepub unsafe fn as_ascii_unchecked(&self) -> &[AsciiChar; N]
🔬This is a nightly-only experimental API. (ascii_char
)
pub unsafe fn as_ascii_unchecked(&self) -> &[AsciiChar; N]
ascii_char
)Converts this array of bytes into a array of ASCII characters, without checking whether they’re valid.
§Safety
Every byte in the array must be in 0..=127
, or else this is UB.
Trait Implementations§
source§impl AsMut<FixedBytes<20>> for Address
impl AsMut<FixedBytes<20>> for Address
source§fn as_mut(&mut self) -> &mut FixedBytes<20>
fn as_mut(&mut self) -> &mut FixedBytes<20>
source§impl AsMut<FixedBytes<24>> for Function
impl AsMut<FixedBytes<24>> for Function
source§fn as_mut(&mut self) -> &mut FixedBytes<24>
fn as_mut(&mut self) -> &mut FixedBytes<24>
source§impl AsMut<FixedBytes<256>> for Bloom
impl AsMut<FixedBytes<256>> for Bloom
source§fn as_mut(&mut self) -> &mut FixedBytes<256>
fn as_mut(&mut self) -> &mut FixedBytes<256>
source§impl AsRef<FixedBytes<20>> for Address
impl AsRef<FixedBytes<20>> for Address
source§fn as_ref(&self) -> &FixedBytes<20>
fn as_ref(&self) -> &FixedBytes<20>
source§impl AsRef<FixedBytes<24>> for Function
impl AsRef<FixedBytes<24>> for Function
source§fn as_ref(&self) -> &FixedBytes<24>
fn as_ref(&self) -> &FixedBytes<24>
source§impl AsRef<FixedBytes<256>> for Bloom
impl AsRef<FixedBytes<256>> for Bloom
source§fn as_ref(&self) -> &FixedBytes<256>
fn as_ref(&self) -> &FixedBytes<256>
source§impl<const N: usize> BitAnd for FixedBytes<N>
impl<const N: usize> BitAnd for FixedBytes<N>
source§impl<const N: usize> BitAndAssign for FixedBytes<N>
impl<const N: usize> BitAndAssign for FixedBytes<N>
source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&=
operation. Read moresource§impl<const N: usize> BitOr for FixedBytes<N>
impl<const N: usize> BitOr for FixedBytes<N>
source§impl<const N: usize> BitOrAssign for FixedBytes<N>
impl<const N: usize> BitOrAssign for FixedBytes<N>
source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|=
operation. Read moresource§impl<const N: usize> BitXor for FixedBytes<N>
impl<const N: usize> BitXor for FixedBytes<N>
source§impl<const N: usize> BitXorAssign for FixedBytes<N>
impl<const N: usize> BitXorAssign for FixedBytes<N>
source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^=
operation. Read moresource§impl<const N: usize> Clone for FixedBytes<N>
impl<const N: usize> Clone for FixedBytes<N>
source§fn clone(&self) -> FixedBytes<N>
fn clone(&self) -> FixedBytes<N>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<const N: usize> Debug for FixedBytes<N>
impl<const N: usize> Debug for FixedBytes<N>
source§impl<const N: usize> Decodable for FixedBytes<N>
Available on crate feature rlp
only.
impl<const N: usize> Decodable for FixedBytes<N>
rlp
only.source§impl<'a, const N: usize> Default for &'a FixedBytes<N>
impl<'a, const N: usize> Default for &'a FixedBytes<N>
source§impl<const N: usize> Default for FixedBytes<N>
impl<const N: usize> Default for FixedBytes<N>
source§impl<const N: usize> Deref for FixedBytes<N>
impl<const N: usize> Deref for FixedBytes<N>
source§impl<const N: usize> DerefMut for FixedBytes<N>
impl<const N: usize> DerefMut for FixedBytes<N>
source§impl<'de, const N: usize> Deserialize<'de> for FixedBytes<N>
Available on crate feature serde
only.
impl<'de, const N: usize> Deserialize<'de> for FixedBytes<N>
serde
only.source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
source§impl<const N: usize> Display for FixedBytes<N>
impl<const N: usize> Display for FixedBytes<N>
source§impl<const N: usize> Encodable for FixedBytes<N>
Available on crate feature rlp
only.
impl<const N: usize> Encodable for FixedBytes<N>
rlp
only.source§impl<const N: usize> From<&'static FixedBytes<N>> for Bytes
impl<const N: usize> From<&'static FixedBytes<N>> for Bytes
source§fn from(value: &'static FixedBytes<N>) -> Self
fn from(value: &'static FixedBytes<N>) -> Self
source§impl From<Address> for FixedBytes<20>
impl From<Address> for FixedBytes<20>
source§impl From<Bloom> for FixedBytes<256>
impl From<Bloom> for FixedBytes<256>
source§impl From<FixedBytes<1>> for I8
impl From<FixedBytes<1>> for I8
source§impl From<FixedBytes<1>> for U8
impl From<FixedBytes<1>> for U8
source§impl From<FixedBytes<1>> for i8
impl From<FixedBytes<1>> for i8
source§impl From<FixedBytes<1>> for u8
impl From<FixedBytes<1>> for u8
source§impl From<FixedBytes<16>> for I128
impl From<FixedBytes<16>> for I128
source§impl From<FixedBytes<16>> for U128
impl From<FixedBytes<16>> for U128
source§impl From<FixedBytes<16>> for i128
impl From<FixedBytes<16>> for i128
source§impl From<FixedBytes<16>> for u128
impl From<FixedBytes<16>> for u128
source§impl From<FixedBytes<2>> for I16
impl From<FixedBytes<2>> for I16
source§impl From<FixedBytes<2>> for U16
impl From<FixedBytes<2>> for U16
source§impl From<FixedBytes<2>> for i16
impl From<FixedBytes<2>> for i16
source§impl From<FixedBytes<2>> for u16
impl From<FixedBytes<2>> for u16
source§impl From<FixedBytes<20>> for Address
impl From<FixedBytes<20>> for Address
source§fn from(value: FixedBytes<20>) -> Self
fn from(value: FixedBytes<20>) -> Self
source§impl From<FixedBytes<20>> for I160
impl From<FixedBytes<20>> for I160
source§impl From<FixedBytes<20>> for U160
impl From<FixedBytes<20>> for U160
source§impl From<FixedBytes<24>> for Function
impl From<FixedBytes<24>> for Function
source§fn from(value: FixedBytes<24>) -> Self
fn from(value: FixedBytes<24>) -> Self
source§impl From<FixedBytes<256>> for Bloom
impl From<FixedBytes<256>> for Bloom
source§fn from(value: FixedBytes<256>) -> Self
fn from(value: FixedBytes<256>) -> Self
source§impl From<FixedBytes<32>> for I256
impl From<FixedBytes<32>> for I256
source§impl From<FixedBytes<32>> for U256
impl From<FixedBytes<32>> for U256
source§impl From<FixedBytes<4>> for I32
impl From<FixedBytes<4>> for I32
source§impl From<FixedBytes<4>> for U32
impl From<FixedBytes<4>> for U32
source§impl From<FixedBytes<4>> for i32
impl From<FixedBytes<4>> for i32
source§impl From<FixedBytes<4>> for u32
impl From<FixedBytes<4>> for u32
source§impl From<FixedBytes<64>> for I512
impl From<FixedBytes<64>> for I512
source§impl From<FixedBytes<64>> for U512
impl From<FixedBytes<64>> for U512
source§impl From<FixedBytes<8>> for I64
impl From<FixedBytes<8>> for I64
source§impl From<FixedBytes<8>> for U64
impl From<FixedBytes<8>> for U64
source§impl From<FixedBytes<8>> for i64
impl From<FixedBytes<8>> for i64
source§impl From<FixedBytes<8>> for u64
impl From<FixedBytes<8>> for u64
source§impl<const N: usize> From<FixedBytes<N>> for [u8; N]
impl<const N: usize> From<FixedBytes<N>> for [u8; N]
source§fn from(s: FixedBytes<N>) -> Self
fn from(s: FixedBytes<N>) -> Self
source§impl<const N: usize> From<FixedBytes<N>> for Bytes
impl<const N: usize> From<FixedBytes<N>> for Bytes
source§fn from(value: FixedBytes<N>) -> Self
fn from(value: FixedBytes<N>) -> Self
source§impl From<Function> for FixedBytes<24>
impl From<Function> for FixedBytes<24>
source§impl<const N: usize> FromHex for FixedBytes<N>
impl<const N: usize> FromHex for FixedBytes<N>
source§impl<const N: usize> FromStr for FixedBytes<N>
impl<const N: usize> FromStr for FixedBytes<N>
source§impl<const N: usize> Hash for FixedBytes<N>
impl<const N: usize> Hash for FixedBytes<N>
source§impl<__IdxT, const N: usize> Index<__IdxT> for FixedBytes<N>
impl<__IdxT, const N: usize> Index<__IdxT> for FixedBytes<N>
source§impl<__IdxT, const N: usize> IndexMut<__IdxT> for FixedBytes<N>
impl<__IdxT, const N: usize> IndexMut<__IdxT> for FixedBytes<N>
source§impl<'__deriveMoreLifetime, const N: usize> IntoIterator for &'__deriveMoreLifetime FixedBytes<N>
impl<'__deriveMoreLifetime, const N: usize> IntoIterator for &'__deriveMoreLifetime FixedBytes<N>
source§impl<'__deriveMoreLifetime, const N: usize> IntoIterator for &'__deriveMoreLifetime mut FixedBytes<N>
impl<'__deriveMoreLifetime, const N: usize> IntoIterator for &'__deriveMoreLifetime mut FixedBytes<N>
source§impl<const N: usize> IntoIterator for FixedBytes<N>
impl<const N: usize> IntoIterator for FixedBytes<N>
source§impl<const N: usize> LowerHex for FixedBytes<N>
impl<const N: usize> LowerHex for FixedBytes<N>
source§impl<const N: usize> MaxEncodedLenAssoc for FixedBytes<N>
Available on crate feature rlp
only.
impl<const N: usize> MaxEncodedLenAssoc for FixedBytes<N>
rlp
only.source§impl<const N: usize> Not for FixedBytes<N>
impl<const N: usize> Not for FixedBytes<N>
source§impl<const N: usize> Ord for FixedBytes<N>
impl<const N: usize> Ord for FixedBytes<N>
source§fn cmp(&self, other: &FixedBytes<N>) -> Ordering
fn cmp(&self, other: &FixedBytes<N>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<const N: usize> PartialEq<&[u8]> for FixedBytes<N>
impl<const N: usize> PartialEq<&[u8]> for FixedBytes<N>
source§impl<const N: usize> PartialEq<&[u8; N]> for FixedBytes<N>
impl<const N: usize> PartialEq<&[u8; N]> for FixedBytes<N>
source§impl<const N: usize> PartialEq<&FixedBytes<N>> for [u8]
impl<const N: usize> PartialEq<&FixedBytes<N>> for [u8]
source§fn eq(&self, other: &&FixedBytes<N>) -> bool
fn eq(&self, other: &&FixedBytes<N>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<const N: usize> PartialEq<&FixedBytes<N>> for [u8; N]
impl<const N: usize> PartialEq<&FixedBytes<N>> for [u8; N]
source§fn eq(&self, other: &&FixedBytes<N>) -> bool
fn eq(&self, other: &&FixedBytes<N>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<const N: usize> PartialEq<[u8]> for &FixedBytes<N>
impl<const N: usize> PartialEq<[u8]> for &FixedBytes<N>
source§impl<const N: usize> PartialEq<[u8]> for FixedBytes<N>
impl<const N: usize> PartialEq<[u8]> for FixedBytes<N>
source§impl<const N: usize> PartialEq<[u8; N]> for &FixedBytes<N>
impl<const N: usize> PartialEq<[u8; N]> for &FixedBytes<N>
source§impl<const N: usize> PartialEq<[u8; N]> for FixedBytes<N>
impl<const N: usize> PartialEq<[u8; N]> for FixedBytes<N>
source§impl<const N: usize> PartialEq<FixedBytes<N>> for &[u8]
impl<const N: usize> PartialEq<FixedBytes<N>> for &[u8]
source§fn eq(&self, other: &FixedBytes<N>) -> bool
fn eq(&self, other: &FixedBytes<N>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<const N: usize> PartialEq<FixedBytes<N>> for &[u8; N]
impl<const N: usize> PartialEq<FixedBytes<N>> for &[u8; N]
source§fn eq(&self, other: &FixedBytes<N>) -> bool
fn eq(&self, other: &FixedBytes<N>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<const N: usize> PartialEq<FixedBytes<N>> for [u8]
impl<const N: usize> PartialEq<FixedBytes<N>> for [u8]
source§fn eq(&self, other: &FixedBytes<N>) -> bool
fn eq(&self, other: &FixedBytes<N>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<const N: usize> PartialEq<FixedBytes<N>> for [u8; N]
impl<const N: usize> PartialEq<FixedBytes<N>> for [u8; N]
source§fn eq(&self, other: &FixedBytes<N>) -> bool
fn eq(&self, other: &FixedBytes<N>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<const N: usize> PartialEq for FixedBytes<N>
impl<const N: usize> PartialEq for FixedBytes<N>
source§fn eq(&self, other: &FixedBytes<N>) -> bool
fn eq(&self, other: &FixedBytes<N>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<const N: usize> PartialOrd<&[u8]> for FixedBytes<N>
impl<const N: usize> PartialOrd<&[u8]> for FixedBytes<N>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<const N: usize> PartialOrd<&FixedBytes<N>> for [u8]
impl<const N: usize> PartialOrd<&FixedBytes<N>> for [u8]
source§fn partial_cmp(&self, other: &&FixedBytes<N>) -> Option<Ordering>
fn partial_cmp(&self, other: &&FixedBytes<N>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<const N: usize> PartialOrd<[u8]> for &FixedBytes<N>
impl<const N: usize> PartialOrd<[u8]> for &FixedBytes<N>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<const N: usize> PartialOrd<[u8]> for FixedBytes<N>
impl<const N: usize> PartialOrd<[u8]> for FixedBytes<N>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<const N: usize> PartialOrd<FixedBytes<N>> for &[u8]
impl<const N: usize> PartialOrd<FixedBytes<N>> for &[u8]
source§fn partial_cmp(&self, other: &FixedBytes<N>) -> Option<Ordering>
fn partial_cmp(&self, other: &FixedBytes<N>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<const N: usize> PartialOrd<FixedBytes<N>> for [u8]
impl<const N: usize> PartialOrd<FixedBytes<N>> for [u8]
source§fn partial_cmp(&self, other: &FixedBytes<N>) -> Option<Ordering>
fn partial_cmp(&self, other: &FixedBytes<N>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<const N: usize> PartialOrd for FixedBytes<N>
impl<const N: usize> PartialOrd for FixedBytes<N>
source§fn partial_cmp(&self, other: &FixedBytes<N>) -> Option<Ordering>
fn partial_cmp(&self, other: &FixedBytes<N>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<const N: usize> Serialize for FixedBytes<N>
Available on crate feature serde
only.
impl<const N: usize> Serialize for FixedBytes<N>
serde
only.source§impl<'a, const N: usize> TryFrom<&'a [u8]> for &'a FixedBytes<N>
impl<'a, const N: usize> TryFrom<&'a [u8]> for &'a FixedBytes<N>
Tries to create a ref FixedBytes<N>
by copying from a slice &[u8]
.
Succeeds if slice.len() == N
.
§type Error = TryFromSliceError
type Error = TryFromSliceError
source§impl<const N: usize> TryFrom<&[u8]> for FixedBytes<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
.
source§impl<'a, const N: usize> TryFrom<&'a mut [u8]> for &'a mut FixedBytes<N>
impl<'a, const N: usize> TryFrom<&'a mut [u8]> for &'a mut FixedBytes<N>
Tries to create a ref FixedBytes<N>
by copying from a mutable slice &mut [u8]
. Succeeds if slice.len() == N
.
§type Error = TryFromSliceError
type Error = TryFromSliceError
source§impl<const N: usize> TryFrom<&mut [u8]> for FixedBytes<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
.
source§impl<const N: usize> UpperHex for FixedBytes<N>
impl<const N: usize> UpperHex for FixedBytes<N>
impl<const N: usize> Copy for FixedBytes<N>
impl<const N: usize> Eq for FixedBytes<N>
impl MaxEncodedLen<{ $sz + length_of_length($sz) }> for FixedBytes<0>
rlp
only.impl MaxEncodedLen<{ $sz + length_of_length($sz) }> for FixedBytes<1>
rlp
only.impl MaxEncodedLen<{ $sz + length_of_length($sz) }> for FixedBytes<1024>
rlp
only.impl MaxEncodedLen<{ $sz + length_of_length($sz) }> for FixedBytes<128>
rlp
only.impl MaxEncodedLen<{ $sz + length_of_length($sz) }> for FixedBytes<16>
rlp
only.impl MaxEncodedLen<{ $sz + length_of_length($sz) }> for FixedBytes<2>
rlp
only.impl MaxEncodedLen<{ $sz + length_of_length($sz) }> for FixedBytes<20>
rlp
only.impl MaxEncodedLen<{ $sz + length_of_length($sz) }> for FixedBytes<256>
rlp
only.impl MaxEncodedLen<{ $sz + length_of_length($sz) }> for FixedBytes<32>
rlp
only.impl MaxEncodedLen<{ $sz + length_of_length($sz) }> for FixedBytes<4>
rlp
only.impl MaxEncodedLen<{ $sz + length_of_length($sz) }> for FixedBytes<512>
rlp
only.impl MaxEncodedLen<{ $sz + length_of_length($sz) }> for FixedBytes<64>
rlp
only.impl MaxEncodedLen<{ $sz + length_of_length($sz) }> for FixedBytes<8>
rlp
only.impl<const N: usize> StructuralPartialEq for FixedBytes<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for FixedBytes<N>
impl<const N: usize> RefUnwindSafe for FixedBytes<N>
impl<const N: usize> Send for FixedBytes<N>
impl<const N: usize> Sync for FixedBytes<N>
impl<const N: usize> Unpin for FixedBytes<N>
impl<const N: usize> UnwindSafe for FixedBytes<N>
Blanket Implementations§
source§impl<A, T> AsBits<T> for A
impl<A, T> AsBits<T> for A
source§impl<A, T> AsMutBits<T> for A
impl<A, T> AsMutBits<T> for A
source§fn as_mut_bits<O>(&mut self) -> &mut BitSlice<T, O>where
O: BitOrder,
fn as_mut_bits<O>(&mut self) -> &mut BitSlice<T, O>where
O: BitOrder,
self
as a mutable bit-slice region with the O
ordering.source§fn try_as_mut_bits<O>(&mut self) -> Result<&mut BitSlice<T, O>, BitSpanError<T>>where
O: BitOrder,
fn try_as_mut_bits<O>(&mut self) -> Result<&mut BitSlice<T, O>, BitSpanError<T>>where
O: BitOrder,
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
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.source§impl<T> ToHex for T
impl<T> ToHex for T
source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
ToHexExt
insteadself
into the result.
Lower case letters are used (e.g. f9b4ca
).source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
ToHexExt
insteadself
into the result.
Upper case letters are used (e.g. F9B4CA
).source§impl<T> ToHexExt for T
impl<T> ToHexExt for T
source§fn encode_hex(&self) -> String
fn encode_hex(&self) -> String
self
into the result.
Lower case letters are used (e.g. f9b4ca
).source§fn encode_hex_upper(&self) -> String
fn encode_hex_upper(&self) -> String
self
into the result.
Upper case letters are used (e.g. F9B4CA
).source§fn encode_hex_with_prefix(&self) -> String
fn encode_hex_with_prefix(&self) -> String
self
into the result with prefix 0x
.
Lower case letters are used (e.g. 0xf9b4ca
).source§fn encode_hex_upper_with_prefix(&self) -> String
fn encode_hex_upper_with_prefix(&self) -> String
self
into the result with prefix 0X
.
Upper case letters are used (e.g. 0xF9B4CA
).