alloy_consensus

Struct Sealed

source
pub struct Sealed<T> { /* private fields */ }
Expand description

A consensus hashable item, with its memoized hash.

We do not implement any specific hashing algorithm here. Instead types implement the Sealable trait to provide define their own hash.

Implementations§

source§

impl<T> Sealed<T>

source

pub fn new(inner: T) -> Sealed<T>
where T: Sealable,

Seal the inner item.

source

pub fn new_ref(inner: &T) -> Sealed<&T>
where T: Sealable,

Seal the inner item, by reference.

source

pub fn new_with<F>(inner: T, f: F) -> Sealed<T>
where F: FnOnce(&T) -> FixedBytes<32>,

Seal the inner item with some function.

source

pub fn new_ref_with<F>(inner: &T, f: F) -> Sealed<&T>
where F: FnOnce(&T) -> FixedBytes<32>,

Seal a reference to the inner item with some function.

source

pub const fn new_unchecked(inner: T, seal: FixedBytes<32>) -> Sealed<T>

Instantiate without performing the hash. This should be used carefully.

source

pub fn into_parts(self) -> (T, FixedBytes<32>)

Decompose into parts.

source

pub fn split(self) -> (T, FixedBytes<32>)

Decompose into parts. Alias for Self::into_parts.

source

pub const fn inner(&self) -> &T

Get the inner item.

source

pub const fn seal(&self) -> FixedBytes<32>

Get the hash.

source

pub fn into_inner(self) -> T

Unseal the inner item, discarding the hash.

source

pub fn unseal(self) -> T

Unseal the inner item, discarding the hash. Alias for Self::into_inner.

Trait Implementations§

source§

impl<'a, T> Arbitrary<'a> for Sealed<T>
where T: for<'b> Arbitrary<'b> + Sealable,

Available on crate feature arbitrary only.
source§

fn arbitrary(u: &mut Unstructured<'a>) -> Result<Sealed<T>, Error>

Generate an arbitrary value of Self from the given unstructured data. Read more
source§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
source§

impl<T> Arbitrary for Sealed<T>
where T: Arbitrary,

source§

type Parameters = (<T as Arbitrary>::Parameters, <FixedBytes<32> as Arbitrary>::Parameters)

The type of parameters that arbitrary_with accepts for configuration of the generated Strategy. Parameters must implement Default.
source§

type Strategy = Map<(<T as Arbitrary>::Strategy, <FixedBytes<32> as Arbitrary>::Strategy), fn(_: (T, FixedBytes<32>)) -> Sealed<T>>

The type of Strategy used to generate values of type Self.
source§

fn arbitrary_with( _top: <Sealed<T> as Arbitrary>::Parameters, ) -> <Sealed<T> as Arbitrary>::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args. Read more
source§

fn arbitrary() -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). Read more
source§

impl<T> Clone for Sealed<T>
where T: Clone,

source§

fn clone(&self) -> Sealed<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for Sealed<T>
where T: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<T> Default for Sealed<T>
where T: Sealable + Default,

source§

fn default() -> Sealed<T>

Returns the “default value” for a type. Read more
source§

impl<T> Deref for Sealed<T>

source§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &<Sealed<T> as Deref>::Target

Dereferences the value.
source§

impl<'de, T> Deserialize<'de> for Sealed<T>
where T: Deserialize<'de>,

source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Sealed<T>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T> Hash for Sealed<T>
where T: Hash,

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T> PartialEq for Sealed<T>
where T: PartialEq,

source§

fn eq(&self, other: &Sealed<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> Serialize for Sealed<T>
where T: Serialize,

source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T> Copy for Sealed<T>
where T: Copy,

source§

impl<T> Eq for Sealed<T>
where T: Eq,

source§

impl<T> StructuralPartialEq for Sealed<T>

Auto Trait Implementations§

§

impl<T> Freeze for Sealed<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Sealed<T>
where T: RefUnwindSafe,

§

impl<T> Send for Sealed<T>
where T: Send,

§

impl<T> Sync for Sealed<T>
where T: Sync,

§

impl<T> Unpin for Sealed<T>
where T: Unpin,

§

impl<T> UnwindSafe for Sealed<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,