pub trait ShellState {
Show 36 methods
// Required methods
fn is_subshell(&self) -> bool;
fn last_stopwatch_time(&self) -> SystemTime;
fn last_stopwatch_offset(&self) -> u32;
fn env(&self) -> &ShellEnvironment;
fn env_mut(&mut self) -> &mut ShellEnvironment;
fn options(&self) -> &RuntimeOptions;
fn options_mut(&mut self) -> &mut RuntimeOptions;
fn aliases(&self) -> &HashMap<String, String>;
fn aliases_mut(&mut self) -> &mut HashMap<String, String>;
fn jobs(&self) -> &JobManager;
fn jobs_mut(&mut self) -> &mut JobManager;
fn traps(&self) -> &TrapHandlerConfig;
fn traps_mut(&mut self) -> &mut TrapHandlerConfig;
fn directory_stack(&self) -> &[PathBuf];
fn directory_stack_mut(&mut self) -> &mut Vec<PathBuf>;
fn last_pipeline_statuses(&self) -> &[u8] ⓘ;
fn last_pipeline_statuses_mut(&mut self) -> &mut Vec<u8> ⓘ;
fn program_location_cache(&self) -> &PathCache;
fn program_location_cache_mut(&mut self) -> &mut PathCache;
fn completion_config(&self) -> &Config;
fn completion_config_mut(&mut self) -> &mut Config;
fn open_files(&self) -> &OpenFiles;
fn open_files_mut(&mut self) -> &mut OpenFiles;
fn current_shell_name(&self) -> Option<Cow<'_, str>>;
fn depth(&self) -> usize;
fn call_stack(&self) -> &CallStack;
fn history(&self) -> Option<&History>;
fn history_mut(&mut self) -> Option<&mut History>;
fn version(&self) -> Option<&str>;
fn last_exit_status(&self) -> u8;
fn set_last_exit_status(&mut self, status: u8);
fn key_bindings(&self) -> Option<&Arc<Mutex<dyn KeyBindings>>>;
fn set_key_bindings(
&mut self,
key_bindings: Option<Arc<Mutex<dyn KeyBindings>>>,
);
fn working_dir(&self) -> &Path;
fn working_dir_mut(&mut self) -> &mut PathBuf;
fn product_display_str(&self) -> Option<&str>;
}Expand description
A dyn-safe trait for constrained access to shell state.
Required Methods§
Sourcefn is_subshell(&self) -> bool
fn is_subshell(&self) -> bool
Returns whether or not this shell is a subshell.
Sourcefn last_stopwatch_time(&self) -> SystemTime
fn last_stopwatch_time(&self) -> SystemTime
Returns the last “SECONDS” captured time.
Sourcefn last_stopwatch_offset(&self) -> u32
fn last_stopwatch_offset(&self) -> u32
Returns the last “SECONDS” offset requested.
Sourcefn env(&self) -> &ShellEnvironment
fn env(&self) -> &ShellEnvironment
Returns the shell environment containing variables.
Sourcefn env_mut(&mut self) -> &mut ShellEnvironment
fn env_mut(&mut self) -> &mut ShellEnvironment
Returns a mutable reference to the shell environment.
Sourcefn options(&self) -> &RuntimeOptions
fn options(&self) -> &RuntimeOptions
Returns the shell’s runtime options.
Sourcefn options_mut(&mut self) -> &mut RuntimeOptions
fn options_mut(&mut self) -> &mut RuntimeOptions
Returns a mutable reference to the shell’s runtime options.
Sourcefn aliases_mut(&mut self) -> &mut HashMap<String, String>
fn aliases_mut(&mut self) -> &mut HashMap<String, String>
Returns a mutable reference to the shell’s aliases.
Sourcefn jobs(&self) -> &JobManager
fn jobs(&self) -> &JobManager
Returns the shell’s job manager.
Sourcefn jobs_mut(&mut self) -> &mut JobManager
fn jobs_mut(&mut self) -> &mut JobManager
Returns a mutable reference to the shell’s job manager.
Sourcefn traps(&self) -> &TrapHandlerConfig
fn traps(&self) -> &TrapHandlerConfig
Returns the shell’s trap handler configuration.
Sourcefn traps_mut(&mut self) -> &mut TrapHandlerConfig
fn traps_mut(&mut self) -> &mut TrapHandlerConfig
Returns a mutable reference to the shell’s trap handler configuration.
Sourcefn directory_stack(&self) -> &[PathBuf]
fn directory_stack(&self) -> &[PathBuf]
Returns the shell’s directory stack.
Sourcefn directory_stack_mut(&mut self) -> &mut Vec<PathBuf>
fn directory_stack_mut(&mut self) -> &mut Vec<PathBuf>
Returns a mutable reference to the shell’s directory stack.
Sourcefn last_pipeline_statuses(&self) -> &[u8] ⓘ
fn last_pipeline_statuses(&self) -> &[u8] ⓘ
Returns the statuses of commands in the last pipeline.
Sourcefn last_pipeline_statuses_mut(&mut self) -> &mut Vec<u8> ⓘ
fn last_pipeline_statuses_mut(&mut self) -> &mut Vec<u8> ⓘ
Returns a mutable reference to the statuses of commands in the last pipeline.
Sourcefn program_location_cache(&self) -> &PathCache
fn program_location_cache(&self) -> &PathCache
Returns the shell’s program location cache.
Sourcefn program_location_cache_mut(&mut self) -> &mut PathCache
fn program_location_cache_mut(&mut self) -> &mut PathCache
Returns a mutable reference to the shell’s program location cache.
Sourcefn completion_config(&self) -> &Config
fn completion_config(&self) -> &Config
Returns the shell’s completion configuration.
Sourcefn completion_config_mut(&mut self) -> &mut Config
fn completion_config_mut(&mut self) -> &mut Config
Returns a mutable reference to the shell’s completion configuration.
Sourcefn open_files(&self) -> &OpenFiles
fn open_files(&self) -> &OpenFiles
Returns the shell’s open files.
Sourcefn open_files_mut(&mut self) -> &mut OpenFiles
fn open_files_mut(&mut self) -> &mut OpenFiles
Returns a mutable reference to the shell’s open files.
Sourcefn current_shell_name(&self) -> Option<Cow<'_, str>>
fn current_shell_name(&self) -> Option<Cow<'_, str>>
Returns the current name of the shell ($0).
Sourcefn depth(&self) -> usize
fn depth(&self) -> usize
Returns the current subshell depth; 0 is returned if this shell is not a subshell.
Sourcefn call_stack(&self) -> &CallStack
fn call_stack(&self) -> &CallStack
Returns the call stack for the shell.
Sourcefn history_mut(&mut self) -> Option<&mut History>
fn history_mut(&mut self) -> Option<&mut History>
Returns a mutable reference to the shell’s history, if it exists.
Sourcefn last_exit_status(&self) -> u8
fn last_exit_status(&self) -> u8
Returns the exit status of the last command executed in this shell.
Sourcefn set_last_exit_status(&mut self, status: u8)
fn set_last_exit_status(&mut self, status: u8)
Updates the last exit status.
Sourcefn key_bindings(&self) -> Option<&Arc<Mutex<dyn KeyBindings>>>
fn key_bindings(&self) -> Option<&Arc<Mutex<dyn KeyBindings>>>
Returns the key bindings helper for the shell.
Sourcefn set_key_bindings(
&mut self,
key_bindings: Option<Arc<Mutex<dyn KeyBindings>>>,
)
fn set_key_bindings( &mut self, key_bindings: Option<Arc<Mutex<dyn KeyBindings>>>, )
Sets the key bindings helper for the shell.
Sourcefn working_dir(&self) -> &Path
fn working_dir(&self) -> &Path
Returns the shell’s current working directory.
Sourcefn working_dir_mut(&mut self) -> &mut PathBuf
fn working_dir_mut(&mut self) -> &mut PathBuf
Returns a mutable reference to the shell’s current working directory. This is only accessible within the crate.
Sourcefn product_display_str(&self) -> Option<&str>
fn product_display_str(&self) -> Option<&str>
Returns the product display name for this shell.