Skip to main content

ContextStack

Struct ContextStack 

Source
pub struct ContextStack { /* private fields */ }
Expand description

Context stack for nested evaluations

Implementations§

Source§

impl ContextStack

Source

pub fn new(root: Arc<Value>) -> Self

Create a new context stack with Arc root data

Source

pub fn push(&mut self, data: Value)

Pushes a new context frame for nested evaluation (data only).

Source

pub fn push_with_index(&mut self, data: Value, index: usize)

Pushes a frame with just an index (optimized path for array iteration).

Source

pub fn push_with_key_index(&mut self, data: Value, index: usize, key: String)

Pushes a frame with both index and key (optimized path for object iteration).

Source

pub fn replace_top_key_data(&mut self, data: Value, index: usize, key: String)

Replaces data, index, and key in the top frame in-place (for object iteration).

Source

pub fn take_top_data(&mut self) -> Value

Takes the data from the top frame, replacing it with Null.

Source

pub fn replace_top_data(&mut self, data: Value, index: usize)

Replaces the data and index in the top frame in-place.

Source

pub fn push_reduce(&mut self, current: Value, accumulator: Value)

Pushes a reduce frame with “current” and “accumulator” values.

Source

pub fn replace_reduce_data(&mut self, current: Value, accumulator: Value)

Replaces current and accumulator values in the top reduce frame in-place.

Source

pub fn pop(&mut self) -> Option<ContextFrame>

Pops the current context frame from the stack.

Source

pub fn get_at_level(&self, level: isize) -> Option<ContextFrameRef<'_>>

Accesses data at a context level relative to current.

§Arguments
  • level - The number of levels to traverse up the context stack
    • 0: returns the current context
    • N (positive or negative): goes up N levels from current
Source

pub fn current(&self) -> ContextFrameRef<'_>

Get the current context frame (top of stack)

Source

pub fn root(&self) -> ContextFrameRef<'_>

Get the root context frame

Source

pub fn depth(&self) -> usize

Get the current depth (number of frames)

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