pub struct AdviceStackBuilder { /* private fields */ }Expand description
A builder for constructing advice stack inputs with intuitive ordering.
The builder maintains a conceptual advice stack where index 0 is the “top” - i.e., the element that will be consumed first. Method names indicate which MASM instruction pattern they target, abstracting away the internal transformations needed for correct element ordering.
§Building Direction
Building happens “top-first”: the first method call adds elements that will be consumed first by the MASM code. Each subsequent method call adds elements “below” the previous ones.
§Example
let advice = AdviceStackBuilder::new()
.push_for_adv_push(&[a, b, c]) // Consumed first by adv_push.3
.push_for_adv_loadw(word) // Consumed second by adv_loadw
.build();Implementations§
Source§impl AdviceStackBuilder
impl AdviceStackBuilder
Sourcepub fn new() -> AdviceStackBuilder
pub fn new() -> AdviceStackBuilder
Creates a new empty builder.
Sourcepub fn push_element(&mut self, value: Goldilocks) -> &mut AdviceStackBuilder
pub fn push_element(&mut self, value: Goldilocks) -> &mut AdviceStackBuilder
Pushes a single element onto the advice stack.
Elements are consumed in FIFO order: first pushed = first consumed by advice operations.
Sourcepub fn push_elements<I>(&mut self, values: I) -> &mut AdviceStackBuilderwhere
I: IntoIterator<Item = Goldilocks>,
pub fn push_elements<I>(&mut self, values: I) -> &mut AdviceStackBuilderwhere
I: IntoIterator<Item = Goldilocks>,
Extends the advice stack with raw elements (already ordered top-to-bottom).
Elements are consumed in FIFO order: first element in iter = first consumed.
Sourcepub fn push_for_adv_push(
&mut self,
slice: &[Goldilocks],
) -> &mut AdviceStackBuilder
pub fn push_for_adv_push( &mut self, slice: &[Goldilocks], ) -> &mut AdviceStackBuilder
Adds elements for consumption by adv_push.n instructions.
After adv_push.n, the operand stack will have slice[0] on top.
The slice length determines n (e.g., 4-element slice → adv_push.4).
§How it works
adv_push.n pops elements one-by-one from the advice stack and pushes each to the operand
stack. Since each push goes to the top, the first-popped element ends up at the bottom
of the n elements, and the last-popped element ends up on top.
Therefore, this method reverses the slice internally so that slice[0] is popped last
and ends up on top of the operand stack.
§Example
builder.push_for_adv_push(&[a, b, c]);
// MASM: adv_push.3
// Result: operand stack = [a, b, c, ...] with a on topSourcepub fn push_for_adv_loadw(&mut self, word: Word) -> &mut AdviceStackBuilder
pub fn push_for_adv_loadw(&mut self, word: Word) -> &mut AdviceStackBuilder
Adds a word for consumption by padw adv_loadw.
After adv_loadw, the operand stack will have the structural word loaded directly.
Use reversew afterward to convert to canonical (little-endian) order.
§How it works
The adv_loadw instruction:
- Calls
pop_stack_word()which pops 4 elements from front and createsWord::new(\[e0,e1,e2,e3\]) - Places the word on the operand stack with
word\[0\]on top,word\[1\]at position 1, etc.
Elements are pushed without reversal since adv_loadw loads the structural word directly.
§Example
builder.push_for_adv_loadw([w0, w1, w2, w3].into());
// MASM: padw adv_loadw
// Result: operand stack = [w0, w1, w2, w3, ...] with w0 on topSourcepub fn push_for_adv_pipe(
&mut self,
slice: &[Goldilocks],
) -> &mut AdviceStackBuilder
pub fn push_for_adv_pipe( &mut self, slice: &[Goldilocks], ) -> &mut AdviceStackBuilder
Adds elements for sequential consumption by adv_pipe operations.
Elements are consumed in order: slice[0..8] first, then slice[8..16], etc.
No reversal is applied.
§Panics
Panics if the slice length is not a multiple of 8 (double-word aligned).
§Example
builder.push_for_adv_pipe(&elements); // elements.len() must be multiple of 8
// MASM: multiple adv_pipe calls
// Result: elements consumed in order [elements[0], elements[1], ...]Sourcepub fn push_u64_slice(&mut self, values: &[u64]) -> &mut AdviceStackBuilder
pub fn push_u64_slice(&mut self, values: &[u64]) -> &mut AdviceStackBuilder
Extends the advice stack with u64 values converted to Felt.
This is a convenience method for test data that is typically specified as u64. Elements are consumed in FIFO order: first element = first consumed.
§Example
builder.push_u64_slice(&[1, 2, 3, 4, 5, 6, 7, 8]);
// Elements consumed in order: 1, 2, 3, 4, 5, 6, 7, 8Sourcepub fn build(self) -> AdviceInputs
pub fn build(self) -> AdviceInputs
Builds the AdviceInputs from the accumulated stack.
The builder’s conceptual stack (with index 0 as top) is converted to the format
expected by AdviceInputs, which will be reversed when creating an AdviceProvider.
Sourcepub fn build_with(self, map: AdviceMap, store: MerkleStore) -> AdviceInputs
pub fn build_with(self, map: AdviceMap, store: MerkleStore) -> AdviceInputs
Builds the AdviceInputs with additional map and store data.
Sourcepub fn build_vec_u64(self) -> Vec<u64>
pub fn build_vec_u64(self) -> Vec<u64>
Builds just the advice stack as Vec<u64> for use with build_test! macro.
This is a convenience method that avoids needing to modify the test infrastructure.
Sourcepub fn into_elements(self) -> Vec<Goldilocks>
pub fn into_elements(self) -> Vec<Goldilocks>
Consumes the builder and returns the accumulated elements as Vec<Felt>.
Trait Implementations§
Source§impl Clone for AdviceStackBuilder
impl Clone for AdviceStackBuilder
Source§fn clone(&self) -> AdviceStackBuilder
fn clone(&self) -> AdviceStackBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AdviceStackBuilder
impl Debug for AdviceStackBuilder
Source§impl Default for AdviceStackBuilder
impl Default for AdviceStackBuilder
Source§fn default() -> AdviceStackBuilder
fn default() -> AdviceStackBuilder
Auto Trait Implementations§
impl Freeze for AdviceStackBuilder
impl RefUnwindSafe for AdviceStackBuilder
impl Send for AdviceStackBuilder
impl Sync for AdviceStackBuilder
impl Unpin for AdviceStackBuilder
impl UnwindSafe for AdviceStackBuilder
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§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more