pub struct CallStack { /* private fields */ }Expand description
Encapsulates a script call stack.
Implementations§
Source§impl CallStack
impl CallStack
Sourcepub const fn format<'a>(
&'a self,
options: &'a FormatOptions,
) -> FormatCallStack<'a>
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
impl CallStack
Sourcepub fn pop(&mut self) -> Option<Frame>
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.
Sourcepub fn current_frame(&self) -> Option<&Frame>
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.
Sourcepub fn current_pos_as_source_info(&self) -> SourceInfo
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.
Sourcepub fn set_current_pos(&mut self, position: Option<Arc<SourcePosition>>)
pub fn set_current_pos(&mut self, position: Option<Arc<SourcePosition>>)
Updates the currently executing position in the top stack frame.
Sourcepub fn push_script(
&mut self,
call_type: ScriptCallType,
source_info: &SourceInfo,
args: impl IntoIterator<Item = String>,
)
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.
Sourcepub fn push_trap_handler(
&mut self,
signal: TrapSignal,
handler: Option<&TrapHandler>,
)
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.
Sourcepub fn push_command_string(&mut self)
pub fn push_command_string(&mut self)
Pushes a new command string frame onto the stack.
Sourcepub fn push_interactive_session(&mut self)
pub fn push_interactive_session(&mut self)
Pushes a new interactive session frame onto the stack.
Sourcepub fn push_function(
&mut self,
name: impl Into<String>,
function: &Registration,
args: impl IntoIterator<Item = String>,
)
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.
Sourcepub fn iter_function_calls(&self) -> impl Iterator<Item = &FunctionCall>
pub fn iter_function_calls(&self) -> impl Iterator<Item = &FunctionCall>
Iterates through the function calls on the stack.
Sourcepub fn iter_script_calls(&self) -> impl Iterator<Item = &ScriptCall>
pub fn iter_script_calls(&self) -> impl Iterator<Item = &ScriptCall>
Iterates through the script calls on the stack.
Sourcepub fn in_sourced_script(&self) -> bool
pub fn in_sourced_script(&self) -> bool
Returns whether or not the current script stack frame is a sourced script.
Sourcepub const fn function_call_depth(&self) -> usize
pub const fn function_call_depth(&self) -> usize
Returns the current depth of function calls in the call stack.
Sourcepub const fn script_source_depth(&self) -> usize
pub const fn script_source_depth(&self) -> usize
Returns the current depth of sourced script calls in the call stack.
Sourcepub fn is_trap_signal_active(&self, signal: TrapSignal) -> bool
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).
Sourcepub fn clear_active_trap_signals(&mut self)
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.
Sourcepub const fn is_trap_delivery_suppressed(&self) -> bool
pub const fn is_trap_delivery_suppressed(&self) -> bool
Returns whether the given trap signal is currently suppressed.
Sourcepub const fn acquire_trap_delivery_block(&mut self)
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.
Sourcepub const fn release_trap_delivery_block(&mut self)
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.
Sourcepub fn in_function(&self) -> bool
pub fn in_function(&self) -> bool
Returns whether or not the shell is actively executing in a shell function.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CallStack
impl RefUnwindSafe for CallStack
impl Send for CallStack
impl Sync for CallStack
impl Unpin for CallStack
impl UnsafeUnpin for CallStack
impl UnwindSafe for CallStack
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 more