pub struct StackOutputs { /* private fields */ }
Expand description
Output container for Miden VM programs.
Miden program outputs contain the full state of the stack at the end of execution.
stack
is expected to be ordered as if the elements were popped off the stack one by one.
Thus, the value at the top of the stack is expected to be in the first position, and the order
of the rest of the output elements will also match the order on the stack.
Implementations§
Source§impl StackOutputs
impl StackOutputs
Sourcepub fn new(stack: Vec<Felt>) -> Result<Self, OutputError>
pub fn new(stack: Vec<Felt>) -> Result<Self, OutputError>
Constructs a new StackOutputs struct from the provided stack elements.
§Errors
Returns an error if the number of stack elements is greater than MIN_STACK_DEPTH
(16).
Sourcepub fn try_from_ints<I>(iter: I) -> Result<Self, OutputError>where
I: IntoIterator<Item = u64>,
pub fn try_from_ints<I>(iter: I) -> Result<Self, OutputError>where
I: IntoIterator<Item = u64>,
Attempts to create StackOutputs struct from the provided stack elements represented as
vector of u64
values.
§Errors
Returns an error if:
- Any of the provided stack elements are invalid field elements.
Sourcepub fn get_stack_item(&self, idx: usize) -> Option<Felt>
pub fn get_stack_item(&self, idx: usize) -> Option<Felt>
Returns the element located at the specified position on the stack or None
if out of
bounds.
Sourcepub fn get_stack_word(&self, idx: usize) -> Option<Word>
pub fn get_stack_word(&self, idx: usize) -> Option<Word>
Returns the word located starting at the specified Felt position on the stack or None
if
out of bounds. For example, passing in 0
returns the word at the top of the stack, and
passing in 4
returns the word starting at element index 4
.
Sourcepub fn stack_truncated(&self, num_outputs: usize) -> &[Felt]
pub fn stack_truncated(&self, num_outputs: usize) -> &[Felt]
Returns the number of requested stack outputs or returns the full stack if fewer than the requested number of stack values exist.
Sourcepub fn stack_mut(&mut self) -> &mut [Felt]
pub fn stack_mut(&mut self) -> &mut [Felt]
Returns mutable access to the stack outputs, to be used for testing or running examples.
Sourcepub fn as_int_vec(&self) -> Vec<u64>
pub fn as_int_vec(&self) -> Vec<u64>
Converts the StackOutputs
into the vector of u64
values.
Trait Implementations§
Source§impl Clone for StackOutputs
impl Clone for StackOutputs
Source§fn clone(&self) -> StackOutputs
fn clone(&self) -> StackOutputs
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for StackOutputs
impl Debug for StackOutputs
Source§impl Default for StackOutputs
impl Default for StackOutputs
Source§fn default() -> StackOutputs
fn default() -> StackOutputs
Source§impl Deref for StackOutputs
impl Deref for StackOutputs
Source§impl Deserializable for StackOutputs
impl Deserializable for StackOutputs
Source§fn read_from<R: ByteReader>(
source: &mut R,
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>( source: &mut R, ) -> Result<Self, DeserializationError>
source
, attempts to deserialize these bytes
into Self
, and returns the result. Read moreSource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
Source§impl From<[BaseElement; 16]> for StackOutputs
impl From<[BaseElement; 16]> for StackOutputs
Source§impl PartialEq for StackOutputs
impl PartialEq for StackOutputs
Source§impl Serializable for StackOutputs
impl Serializable for StackOutputs
Source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
self
into bytes and writes these bytes into the target
.