miden_processor/host/advice/
source.rs

1use super::{Felt, Word};
2
3// ADVICE SOURCE
4// ================================================================================================
5
6/// Specifies the source of the value(s) to be pushed onto the advice stack.
7#[derive(Copy, Clone, Debug, PartialEq, Eq)]
8pub enum AdviceSource {
9    /// Puts a single value onto the advice stack.
10    Value(Felt),
11
12    /// Puts a word (4 elements) onto the stack.
13    Word(Word),
14
15    /// Fetches a list of elements under the specified key from the advice map and pushes them onto
16    /// the advice stack.
17    ///
18    /// If `include_len` is set to true, this also pushes the number of elements onto the advice
19    /// stack.
20    ///
21    /// Note: this operation doesn't consume the map element so it can be called multiple times
22    /// for the same key.
23    ///
24    /// # Example
25    /// Given an advice stack `[a, b, c, ...]`, and a map `x |-> [d, e, f]`:
26    ///
27    /// A call `push_stack(AdviceSource::Map { key: x, include_len: false })` will result in
28    /// advice stack: `[d, e, f, a, b, c, ...]`.
29    ///
30    /// A call `push_stack(AdviceSource::Map { key: x, include_len: true })` will result in
31    /// advice stack: `[3, d, e, f, a, b, c, ...]`.
32    ///
33    /// # Errors
34    /// Returns an error if the key was not found in the key-value map.
35    Map { key: Word, include_len: bool },
36}