Enum risc0_zkvm::MaybePruned
source · pub enum MaybePruned<T>{
Value(T),
Pruned(Digest),
}
Expand description
Either a source value or a hash Digest of the source value.
This type supports creating “Merkle-ized structs”. Each field of a Merkle-ized struct can have either the full value, or it can be “pruned” and replaced with a digest committing to that value. One way to think of this is as a special Merkle tree of a predefined shape. Each field is a child node. Any field/node in the tree can be opened by providing the Merkle inclusion proof. When a subtree is pruned, the digest commits to the value of all contained fields. ReceiptClaim is the motivating example of this type of Merkle-ized struct.
Variants§
Implementations§
source§impl MaybePruned<Assumptions>
impl MaybePruned<Assumptions>
sourcepub fn add(&mut self, assumption: MaybePruned<ReceiptClaim>)
pub fn add(&mut self, assumption: MaybePruned<ReceiptClaim>)
Add an assumption to the head of the assumptions list.
If this value is pruned, then the result will also be a pruned value.
sourcepub fn resolve(&mut self, resolved: &Digest, tail: &Digest) -> Result<()>
pub fn resolve(&mut self, resolved: &Digest, tail: &Digest) -> Result<()>
Mark an assumption as resolved and remove it from the list.
Assumptions can only be removed from the head of the list. If this value
is pruned, then the result will also be a pruned value. The tail
parameter should be equal to the digest of the list after the
resolved assumption is removed.
source§impl<T> MaybePruned<T>
impl<T> MaybePruned<T>
sourcepub fn value(self) -> Result<T, PrunedValueError>
pub fn value(self) -> Result<T, PrunedValueError>
Unwrap the value, or return an error.
sourcepub fn as_value(&self) -> Result<&T, PrunedValueError>
pub fn as_value(&self) -> Result<&T, PrunedValueError>
Unwrap the value as a reference, or return an error.
sourcepub fn as_value_mut(&mut self) -> Result<&mut T, PrunedValueError>
pub fn as_value_mut(&mut self) -> Result<&mut T, PrunedValueError>
Unwrap the value as a mutable reference, or return an error.
Trait Implementations§
source§impl<T> Clone for MaybePruned<T>
impl<T> Clone for MaybePruned<T>
source§fn clone(&self) -> MaybePruned<T>
fn clone(&self) -> MaybePruned<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T> Debug for MaybePruned<T>
impl<T> Debug for MaybePruned<T>
source§fn fmt(&self, fmt: &mut Formatter<'_>) -> Result
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result
Format MaybePruned values are if they were a struct with value and digest fields. Digest field is always provided so that divergent trees of MaybePruned values can be compared.
source§impl<T> Default for MaybePruned<T>
impl<T> Default for MaybePruned<T>
source§impl<'de, T> Deserialize<'de> for MaybePruned<T>
impl<'de, T> Deserialize<'de> for MaybePruned<T>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<T> Digestible for MaybePruned<T>
impl<T> Digestible for MaybePruned<T>
source§impl From<MaybePruned<ReceiptClaim>> for Assumption
impl From<MaybePruned<ReceiptClaim>> for Assumption
source§fn from(claim: MaybePruned<ReceiptClaim>) -> Self
fn from(claim: MaybePruned<ReceiptClaim>) -> Self
Create an unresolved assumption from a MaybePruned ReceiptClaim.