pub struct Digested<T: Digestible> { /* private fields */ }Expand description
A shared value paired with its Digest.
Digested::compute hashes the value as a job on a Strategy, and
Digested::precomputed pairs it with a digest a local source already computed from this
exact value. Holders read the digest for free and never choose a strategy. The value must
not change anything its digest covers while a carrier refers to it.
Cloning shares the value. Two values are equal when their digests are equal, which the Digestible contract makes equivalent to the values being equal. The value encodes as the inner value does, and there is no decoding. A decoded value is paired with its digest by one of the constructors.
Implementations§
Source§impl<T: Digestible> Digested<T>
impl<T: Digestible> Digested<T>
Sourcepub fn compute(
inner: impl Into<Arc<T>>,
strategy: &impl Strategy,
) -> impl Future<Output = Self> + Send + 'staticwhere
T: EncodeSize,
pub fn compute(
inner: impl Into<Arc<T>>,
strategy: &impl Strategy,
) -> impl Future<Output = Self> + Send + 'staticwhere
T: EncodeSize,
Computes the digest of inner as a job on strategy.
Sourcepub fn precomputed(inner: impl Into<Arc<T>>, digest: T::Digest) -> Self
pub fn precomputed(inner: impl Into<Arc<T>>, digest: T::Digest) -> Self
Pairs inner with a digest already computed from this exact value.
digest must come from a local source bound to inner, such as the key the value was
stored under, a commitment checked against its bytes, or an earlier Self::compute.
It says nothing about whether the value is valid or certified.
Returns a shared reference to the value.
Trait Implementations§
Source§impl<T: Digestible> Clone for Digested<T>
Available on neither commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_GAMMA nor commonware_stability_RESERVED.
impl<T: Digestible> Clone for Digested<T>
commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_GAMMA nor commonware_stability_RESERVED.Source§impl<T: Digestible + Debug> Debug for Digested<T>
Available on neither commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_GAMMA nor commonware_stability_RESERVED.
impl<T: Digestible + Debug> Debug for Digested<T>
commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_GAMMA nor commonware_stability_RESERVED.Source§impl<T: Digestible> Digestible for Digested<T>
Available on neither commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_GAMMA nor commonware_stability_RESERVED.
impl<T: Digestible> Digestible for Digested<T>
commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_GAMMA nor commonware_stability_RESERVED.Source§impl<T: Digestible + EncodeSize> EncodeSize for Digested<T>
Available on neither commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_GAMMA nor commonware_stability_RESERVED.
impl<T: Digestible + EncodeSize> EncodeSize for Digested<T>
commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_GAMMA nor commonware_stability_RESERVED.Source§fn encode_size(&self) -> usize
fn encode_size(&self) -> usize
Source§fn encode_inline_size(&self) -> usize
fn encode_inline_size(&self) -> usize
BufsMut::push
during Write::write_bufs. Used to size the fixed working buffer for
inline writes, so it must not be less than the bytes written inline.
Override alongside Write::write_bufs for types where large
byte fields go via push, or the working buffer will over-allocate.impl<T: Digestible> Eq for Digested<T>
commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_GAMMA nor commonware_stability_RESERVED.Source§impl<T: Digestible> From<Digested<T>> for Arc<T>
Available on neither commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_GAMMA nor commonware_stability_RESERVED.
impl<T: Digestible> From<Digested<T>> for Arc<T>
commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_GAMMA nor commonware_stability_RESERVED.Source§impl<T: Digestible> PartialEq for Digested<T>
Available on neither commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_GAMMA nor commonware_stability_RESERVED.
impl<T: Digestible> PartialEq for Digested<T>
commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_GAMMA nor commonware_stability_RESERVED.Source§impl<T: Digestible + Write> Write for Digested<T>
Available on neither commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_GAMMA nor commonware_stability_RESERVED.
impl<T: Digestible + Write> Write for Digested<T>
commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_GAMMA nor commonware_stability_RESERVED.Source§fn write_bufs(&self, buf: &mut impl BufsMut)
fn write_bufs(&self, buf: &mut impl BufsMut)
BufsMut, allowing existing byte chunks to be
appended via BufsMut::push instead of written inline. Must encode
to the same format as Write::write. Defaults to Write::write.