Skip to main content

CallStack

Struct CallStack 

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

Encapsulates a script call stack.

Implementations§

Source§

impl CallStack

Source

pub const fn format<'a>( &'a self, options: &'a FormatOptions, ) -> FormatCallStack<'a>

Creates a formatter for this call stack with the given options.

§Arguments
  • options - The formatting options to use.
Source§

impl CallStack

Source

pub fn new() -> Self

Creates a new empty script call stack.

Source

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

Removes the top from from the stack. If the stack is empty, does nothing and returns None; otherwise, returns the removed call frame.

Source

pub fn current_frame(&self) -> Option<&Frame>

Returns a reference to the current (topmost) call frame in the stack. Returns None if the stack is empty.

Source

pub fn current_pos_as_source_info(&self) -> SourceInfo

Returns the position in the current (topmost) call frame in the stack, expressed as a new SourceInfo. Note that this may not be identical to that frame’s SourceInfo since it may include an offset representing the current execution position within that source.

Source

pub fn set_current_pos(&mut self, position: Option<Arc<SourcePosition>>)

Updates the currently executing position in the top stack frame.

Source

pub fn push_script( &mut self, call_type: ScriptCallType, source_info: &SourceInfo, args: impl IntoIterator<Item = String>, )

Pushes a new script call frame onto the stack.

§Arguments
  • call_type - The type of script call (sourced or executed).
  • source_info - The source of the script.
  • args - The positional arguments for the script call.
Source

pub fn push_trap_handler( &mut self, signal: TrapSignal, handler: Option<&TrapHandler>, )

Pushes a new trap handler frame onto the stack.

§Arguments
  • signal - The signal being handled.
  • handler - The trap handler being invoked, if any.
Source

pub fn push_eval(&mut self)

Pushes a new eval frame onto the stack.

Source

pub fn push_command_string(&mut self)

Pushes a new command string frame onto the stack.

Source

pub fn push_interactive_session(&mut self)

Pushes a new interactive session frame onto the stack.

Source

pub fn push_function( &mut self, name: impl Into<String>, function: &Registration, args: impl IntoIterator<Item = String>, )

Pushes a new function call frame onto the stack.

§Arguments
  • name - The name of the function being called.
  • function - The function being called.
  • args - The positional arguments for the function call.
Source

pub fn iter_function_calls(&self) -> impl Iterator<Item = &FunctionCall>

Iterates through the function calls on the stack.

Source

pub fn iter_script_calls(&self) -> impl Iterator<Item = &ScriptCall>

Iterates through the script calls on the stack.

Source

pub fn in_sourced_script(&self) -> bool

Returns whether or not the current script stack frame is a sourced script.

Source

pub const fn function_call_depth(&self) -> usize

Returns the current depth of function calls in the call stack.

Source

pub const fn script_source_depth(&self) -> usize

Returns the current depth of sourced script calls in the call stack.

Source

pub fn is_trap_signal_active(&self, signal: TrapSignal) -> bool

Returns whether the given trap signal is currently being handled (i.e., there is an active frame on the stack for this signal).

Source

pub fn clear_active_trap_signals(&mut self)

Clears the set of active trap signals. This should be called when creating subshells so they start with fresh trap execution state independent of the parent shell’s currently-executing traps.

Source

pub const fn is_trap_delivery_suppressed(&self) -> bool

Returns whether the given trap signal is currently suppressed.

Source

pub const fn acquire_trap_delivery_block(&mut self)

Acquires a block on trap delivery, preventing traps from being delivered until the block is released. Multiple blocks may be acquired, and trap delivery will remain suppressed until all blocks have been released.

Source

pub const fn release_trap_delivery_block(&mut self)

Releases a block on trap delivery; note that trap delivery will remain suppressed until all blocks have been released.

Source

pub fn in_function(&self) -> bool

Returns whether or not the shell is actively executing in a shell function.

Source

pub fn depth(&self) -> usize

Returns the current depth of the call stack.

Source

pub fn is_empty(&self) -> bool

Returns whether or not the call stack is empty.

Source

pub fn iter(&self) -> impl Iterator<Item = &Frame>

Returns an iterator over the call frames, starting from the most recent.

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Frame>

Returns a mutable iterator over the call frames, starting from the most recent.

Trait Implementations§

Source§

impl Clone for CallStack

Source§

fn clone(&self) -> CallStack

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 CallStack

Source§

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

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

impl Default for CallStack

Source§

fn default() -> CallStack

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

impl Display for CallStack

Source§

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

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

impl Index<usize> for CallStack

Source§

type Output = Frame

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more