Struct alloy_primitives::Bloom
source · #[repr(transparent)]pub struct Bloom(pub FixedBytes<256>);Expand description
Ethereum 256 byte bloom filter.
Tuple Fields§
§0: FixedBytes<256>Implementations§
source§impl Bloom
impl Bloom
sourcepub const fn with_last_byte(x: u8) -> Self
pub const fn with_last_byte(x: u8) -> Self
Creates a new byte array 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 byte array where all bytes are set to byte.
sourcepub fn random() -> Self
pub fn random() -> Self
Instantiates a new fixed byte array with cryptographically random content.
Panics
This function panics if the underlying call to getrandom_uninit
fails.
sourcepub fn try_random() -> Result<Self, Error>
pub fn try_random() -> Result<Self, Error>
Tries to create a new fixed byte array with cryptographically random content.
Errors
This function only propagates the error from the underlying call to
getrandom_uninit.
sourcepub fn randomize(&mut self)
pub fn randomize(&mut self)
Fills this fixed byte array with cryptographically random content.
Panics
This function panics if the underlying call to getrandom_uninit fails.
sourcepub fn try_randomize(&mut self) -> Result<(), Error>
pub fn try_randomize(&mut self) -> Result<(), Error>
Tries to fill this fixed byte array with cryptographically random content.
Errors
This function only propagates the error from the underlying call to
getrandom_uninit.
sourcepub fn random_with<R: Rng + ?Sized>(rng: &mut R) -> Self
pub fn random_with<R: Rng + ?Sized>(rng: &mut R) -> Self
Creates a new fixed byte array with the given random number generator.
sourcepub fn randomize_with<R: Rng + ?Sized>(&mut self, rng: &mut R)
pub fn randomize_with<R: Rng + ?Sized>(&mut self, rng: &mut R)
Fills this fixed byte array with the given random number generator.
sourcepub fn from_slice(src: &[u8]) -> Self
pub fn from_slice(src: &[u8]) -> Self
sourcepub const fn into_array(self) -> [u8; 256]
pub const fn into_array(self) -> [u8; 256]
Returns the inner bytes array.
source§impl Bloom
impl Bloom
sourcepub fn data_mut(&mut self) -> &mut [u8; 256]
pub fn data_mut(&mut self) -> &mut [u8; 256]
Returns a mutable reference to the underlying data.
sourcepub fn contains_input(&self, input: BloomInput<'_>) -> bool
pub fn contains_input(&self, input: BloomInput<'_>) -> bool
Returns true if this bloom filter is a possible superset of the other bloom filter, admitting false positives.
sourcepub const fn const_contains(self, other: Self) -> bool
pub const fn const_contains(self, other: Self) -> bool
Compile-time version of contains.
sourcepub fn contains(&self, other: &Self) -> bool
pub fn contains(&self, other: &Self) -> bool
Returns true if this bloom filter is a possible superset of the other bloom filter, admitting false positives.
sourcepub fn accrue(&mut self, input: BloomInput<'_>)
pub fn accrue(&mut self, input: BloomInput<'_>)
Accrues the input into the bloom filter.
sourcepub fn accrue_bloom(&mut self, bloom: &Self)
pub fn accrue_bloom(&mut self, bloom: &Self)
Accrues the input into the bloom filter.
sourcepub fn m3_2048(&mut self, bytes: &[u8])
pub fn m3_2048(&mut self, bytes: &[u8])
Specialised Bloom filter that sets three bits out of 2048, given an arbitrary byte sequence.
See Section 4.3.1 “Transaction Receipt” of the Ethereum Yellow Paper (page 6).
sourcepub fn m3_2048_hashed(&mut self, hash: &B256)
pub fn m3_2048_hashed(&mut self, hash: &B256)
m3_2048 but with a pre-hashed input.
sourcepub fn logs_bloom<A, TS, T, I>(logs: I) -> Selfwhere
A: Borrow<[u8; 20]>,
TS: IntoIterator<Item = T>,
T: Borrow<[u8; 32]>,
I: IntoIterator<Item = (A, TS)>,
pub fn logs_bloom<A, TS, T, I>(logs: I) -> Selfwhere A: Borrow<[u8; 20]>, TS: IntoIterator<Item = T>, T: Borrow<[u8; 32]>, I: IntoIterator<Item = (A, TS)>,
Calculate a transaction receipt’s logs bloom.
Methods from Deref<Target = FixedBytes<256>>§
pub const ZERO: Self = _
sourcepub fn randomize(&mut self)
Available on crate feature getrandom only.
pub fn randomize(&mut self)
getrandom only.Fills this FixedBytes with cryptographically random content.
Panics
This function panics if the underlying call to
getrandom_uninit fails.
sourcepub 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 cryptographically random content.
Errors
This function only propagates the error from the underlying call to
getrandom_uninit.
sourcepub fn randomize_with<R: Rng + ?Sized>(&mut self, rng: &mut R)
Available on crate feature rand only.
pub fn randomize_with<R: Rng + ?Sized>(&mut self, rng: &mut R)
rand only.Fills this FixedBytes with the given random number generator.
sourcepub fn as_slice(&self) -> &[u8] ⓘ
pub 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 fn const_eq(&self, other: &Self) -> bool
pub fn const_eq(&self, other: &Self) -> bool
Compile-time equality. NOT constant-time equality.
sourcepub fn const_is_zero(&self) -> bool
pub 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[..].
sourcepub fn each_ref(&self) -> [&T; N]
🔬This is a nightly-only experimental API. (array_methods)
pub fn each_ref(&self) -> [&T; N]
array_methods)Borrows each element and returns an array of references with the same
size as self.
Example
#![feature(array_methods)]
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.
#![feature(array_methods)]
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);sourcepub fn each_mut(&mut self) -> [&mut T; N]
🔬This is a nightly-only experimental API. (array_methods)
pub fn each_mut(&mut self) -> [&mut T; N]
array_methods)Borrows each element mutably and returns an array of mutable references
with the same size as self.
Example
#![feature(array_methods)]
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<'a> Arbitrary<'a> for Bloom
impl<'a> Arbitrary<'a> for Bloom
source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moresource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self>
Self from the entirety of the given
unstructured data. Read moresource§impl Arbitrary for Bloom
impl Arbitrary for Bloom
§type Parameters = <FixedBytes<256> as Arbitrary>::Parameters
type Parameters = <FixedBytes<256> as Arbitrary>::Parameters
arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default.§type Strategy = Map<<FixedBytes<256> as Arbitrary>::Strategy, fn(_: FixedBytes<256>) -> Bloom>
type Strategy = Map<<FixedBytes<256> as Arbitrary>::Strategy, fn(_: FixedBytes<256>) -> Bloom>
Strategy used to generate values of type Self.source§fn arbitrary_with(args: Self::Parameters) -> Self::Strategy
fn arbitrary_with(args: Self::Parameters) -> Self::Strategy
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<256>> for Bloom
impl AsRef<FixedBytes<256>> for Bloom
source§fn as_ref(&self) -> &FixedBytes<256>
fn as_ref(&self) -> &FixedBytes<256>
source§impl BitAndAssign for Bloom
impl BitAndAssign for Bloom
source§fn bitand_assign(&mut self, rhs: Bloom)
fn bitand_assign(&mut self, rhs: Bloom)
&= operation. Read moresource§impl BitOrAssign for Bloom
impl BitOrAssign for Bloom
source§fn bitor_assign(&mut self, rhs: Bloom)
fn bitor_assign(&mut self, rhs: Bloom)
|= operation. Read moresource§impl BitXorAssign for Bloom
impl BitXorAssign for Bloom
source§fn bitxor_assign(&mut self, rhs: Bloom)
fn bitxor_assign(&mut self, rhs: Bloom)
^= operation. Read moresource§impl<'de> Deserialize<'de> for Bloom
impl<'de> Deserialize<'de> for Bloom
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 Distribution<Bloom> for Standard
impl Distribution<Bloom> for Standard
source§fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Bloom
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Bloom
T, using rng as the source of randomness.source§impl From<Bloom> for FixedBytes<256>
impl From<Bloom> for FixedBytes<256>
source§impl From<BloomInput<'_>> for Bloom
impl From<BloomInput<'_>> for Bloom
source§fn from(input: BloomInput<'_>) -> Self
fn from(input: BloomInput<'_>) -> Self
source§impl From<FixedBytes<256>> for Bloom
impl From<FixedBytes<256>> for Bloom
source§fn from(original: FixedBytes<256>) -> Bloom
fn from(original: FixedBytes<256>) -> Bloom
source§impl<'__deriveMoreLifetime> IntoIterator for &'__deriveMoreLifetime Bloom
impl<'__deriveMoreLifetime> IntoIterator for &'__deriveMoreLifetime Bloom
§type Item = <&'__deriveMoreLifetime FixedBytes<256> as IntoIterator>::Item
type Item = <&'__deriveMoreLifetime FixedBytes<256> as IntoIterator>::Item
§type IntoIter = <&'__deriveMoreLifetime FixedBytes<256> as IntoIterator>::IntoIter
type IntoIter = <&'__deriveMoreLifetime FixedBytes<256> as IntoIterator>::IntoIter
source§impl<'__deriveMoreLifetime> IntoIterator for &'__deriveMoreLifetime mut Bloom
impl<'__deriveMoreLifetime> IntoIterator for &'__deriveMoreLifetime mut Bloom
§type Item = <&'__deriveMoreLifetime mut FixedBytes<256> as IntoIterator>::Item
type Item = <&'__deriveMoreLifetime mut FixedBytes<256> as IntoIterator>::Item
§type IntoIter = <&'__deriveMoreLifetime mut FixedBytes<256> as IntoIterator>::IntoIter
type IntoIter = <&'__deriveMoreLifetime mut FixedBytes<256> as IntoIterator>::IntoIter
source§impl IntoIterator for Bloom
impl IntoIterator for Bloom
§type Item = <FixedBytes<256> as IntoIterator>::Item
type Item = <FixedBytes<256> as IntoIterator>::Item
§type IntoIter = <FixedBytes<256> as IntoIterator>::IntoIter
type IntoIter = <FixedBytes<256> as IntoIterator>::IntoIter
source§impl Ord for Bloom
impl Ord for Bloom
source§impl PartialEq<&[u8]> for Bloom
impl PartialEq<&[u8]> for Bloom
source§impl PartialEq<&[u8; 256]> for Bloom
impl PartialEq<&[u8; 256]> for Bloom
source§impl PartialEq<&Bloom> for [u8]
impl PartialEq<&Bloom> for [u8]
source§impl PartialEq<&Bloom> for [u8; 256]
impl PartialEq<&Bloom> for [u8; 256]
source§impl PartialEq<[u8]> for &Bloom
impl PartialEq<[u8]> for &Bloom
source§impl PartialEq<[u8]> for Bloom
impl PartialEq<[u8]> for Bloom
source§impl PartialEq<[u8; 256]> for &Bloom
impl PartialEq<[u8; 256]> for &Bloom
source§impl PartialEq<[u8; 256]> for Bloom
impl PartialEq<[u8; 256]> for Bloom
source§impl PartialEq<Bloom> for &[u8]
impl PartialEq<Bloom> for &[u8]
source§impl PartialEq<Bloom> for &[u8; 256]
impl PartialEq<Bloom> for &[u8; 256]
source§impl PartialEq<Bloom> for [u8]
impl PartialEq<Bloom> for [u8]
source§impl PartialEq<Bloom> for [u8; 256]
impl PartialEq<Bloom> for [u8; 256]
source§impl PartialEq for Bloom
impl PartialEq for Bloom
source§impl PartialOrd<&[u8]> for Bloom
impl PartialOrd<&[u8]> for Bloom
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 PartialOrd<&Bloom> for [u8]
impl PartialOrd<&Bloom> for [u8]
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 PartialOrd<[u8]> for &Bloom
impl PartialOrd<[u8]> for &Bloom
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 PartialOrd<[u8]> for Bloom
impl PartialOrd<[u8]> for Bloom
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 PartialOrd<Bloom> for &[u8]
impl PartialOrd<Bloom> for &[u8]
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 PartialOrd<Bloom> for [u8]
impl PartialOrd<Bloom> for [u8]
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 PartialOrd for Bloom
impl PartialOrd for Bloom
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 moreimpl Copy for Bloom
impl Eq for Bloom
impl MaxEncodedLen<{ $len }> for Bloom
impl StructuralEq for Bloom
impl StructuralPartialEq for Bloom
Auto Trait Implementations§
impl RefUnwindSafe for Bloom
impl Send for Bloom
impl Sync for Bloom
impl Unpin for Bloom
impl UnwindSafe for Bloom
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
source§impl<T> ToHex for Twhere
T: AsRef<[u8]>,
impl<T> ToHex for Twhere T: AsRef<[u8]>,
source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere U: FromIterator<char>,
self 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>,
self into the result. Upper case
letters are used (e.g. F9B4CA)