Struct miden_core::mast::LoopNode
source · pub struct LoopNode { /* private fields */ }Expand description
A Loop node defines condition-controlled iterative execution. When the VM encounters a Loop node, it will keep executing the body of the loop as long as the top of the stack is `1``.
The loop is exited when at the end of executing the loop body the top of the stack is 0``. If the top of the stack is neither 0nor1` when the condition is checked, the execution
fails.
Implementations§
source§impl LoopNode
impl LoopNode
Constructors
sourcepub fn new(
body: MastNodeId,
mast_forest: &MastForest,
) -> Result<Self, MastForestError>
pub fn new( body: MastNodeId, mast_forest: &MastForest, ) -> Result<Self, MastForestError>
Returns a new LoopNode instantiated with the specified body node.
sourcepub fn new_unsafe(body: MastNodeId, digest: RpoDigest) -> Self
pub fn new_unsafe(body: MastNodeId, digest: RpoDigest) -> Self
Returns a new LoopNode from values that are assumed to be correct.
Should only be used when the source of the inputs is trusted (e.g. deserialization).
source§impl LoopNode
impl LoopNode
sourcepub fn digest(&self) -> RpoDigest
pub fn digest(&self) -> RpoDigest
Returns a commitment to this Loop node.
The commitment is computed as a hash of the loop body and an empty word ([ZERO; 4]) in the domain defined by Self::DOMAIN - i..e,:
Hasher::merge_in_domain(&[body_digest, Digest::default()], LoopNode::DOMAIN);sourcepub fn body(&self) -> MastNodeId
pub fn body(&self) -> MastNodeId
Returns the ID of the node presenting the body of the loop.
Trait Implementations§
impl Eq for LoopNode
impl StructuralPartialEq for LoopNode
Auto Trait Implementations§
impl Freeze for LoopNode
impl RefUnwindSafe for LoopNode
impl Send for LoopNode
impl Sync for LoopNode
impl Unpin for LoopNode
impl UnwindSafe for LoopNode
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)