Struct StackOutputs

Source
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

Source

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).

Source

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.
Source

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.

Source

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.

Source

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.

Source

pub fn stack_mut(&mut self) -> &mut [Felt]

Returns mutable access to the stack outputs, to be used for testing or running examples.

Source

pub fn as_int_vec(&self) -> Vec<u64>

Converts the StackOutputs into the vector of u64 values.

Trait Implementations§

Source§

impl Clone for StackOutputs

Source§

fn clone(&self) -> StackOutputs

Returns a duplicate 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 Debug for StackOutputs

Source§

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

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

impl Default for StackOutputs

Source§

fn default() -> StackOutputs

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

impl Deref for StackOutputs

Source§

type Target = [BaseElement; 16]

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Deserializable for StackOutputs

Source§

fn read_from<R: ByteReader>( source: &mut R, ) -> Result<Self, DeserializationError>

Reads a sequence of bytes from the provided source, attempts to deserialize these bytes into Self, and returns the result. Read more
Source§

fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>

Attempts to deserialize the provided bytes into Self and returns the result. Read more
Source§

impl From<[BaseElement; 16]> for StackOutputs

Source§

fn from(value: [Felt; 16]) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for StackOutputs

Source§

fn eq(&self, other: &StackOutputs) -> 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 Serializable for StackOutputs

Source§

fn write_into<W: ByteWriter>(&self, target: &mut W)

Serializes self into bytes and writes these bytes into the target.
Source§

fn to_bytes(&self) -> Vec<u8>

Serializes self into a vector of bytes.
Source§

fn get_size_hint(&self) -> usize

Returns an estimate of how many bytes are needed to represent self. Read more
Source§

impl Eq for StackOutputs

Source§

impl StructuralPartialEq for StackOutputs

Auto Trait Implementations§

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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