nu_plugin_engine

Trait PluginExecutionContext

Source
pub trait PluginExecutionContext: Send + Sync {
Show 15 methods // Required methods fn span(&self) -> Span; fn signals(&self) -> &Signals; fn pipeline_externals_state(&self) -> Option<&Arc<(AtomicU32, AtomicU32)>>; fn get_config(&self) -> Result<Arc<Config>, ShellError>; fn get_plugin_config(&self) -> Result<Option<Value>, ShellError>; fn get_env_var(&self, name: &str) -> Result<Option<&Value>, ShellError>; fn get_env_vars(&self) -> Result<HashMap<String, Value>, ShellError>; fn get_current_dir(&self) -> Result<Spanned<String>, ShellError>; fn add_env_var( &mut self, name: String, value: Value, ) -> Result<(), ShellError>; fn get_help(&self) -> Result<Spanned<String>, ShellError>; fn get_span_contents( &self, span: Span, ) -> Result<Spanned<Vec<u8>>, ShellError>; fn eval_closure( &self, closure: Spanned<Closure>, positional: Vec<Value>, input: PipelineData, redirect_stdout: bool, redirect_stderr: bool, ) -> Result<PipelineData, ShellError>; fn find_decl(&self, name: &str) -> Result<Option<DeclId>, ShellError>; fn call_decl( &mut self, decl_id: DeclId, call: EvaluatedCall, input: PipelineData, redirect_stdout: bool, redirect_stderr: bool, ) -> Result<PipelineData, ShellError>; fn boxed(&self) -> Box<dyn PluginExecutionContext>;
}
Expand description

Object safe trait for abstracting operations required of the plugin context.

Required Methods§

Source

fn span(&self) -> Span

A span pointing to the command being executed

Source

fn signals(&self) -> &Signals

The Signals struct, if present

Source

fn pipeline_externals_state(&self) -> Option<&Arc<(AtomicU32, AtomicU32)>>

The pipeline externals state, for tracking the foreground process group, if present

Source

fn get_config(&self) -> Result<Arc<Config>, ShellError>

Get engine configuration

Source

fn get_plugin_config(&self) -> Result<Option<Value>, ShellError>

Get plugin configuration

Source

fn get_env_var(&self, name: &str) -> Result<Option<&Value>, ShellError>

Get an environment variable from $env

Source

fn get_env_vars(&self) -> Result<HashMap<String, Value>, ShellError>

Get all environment variables

Source

fn get_current_dir(&self) -> Result<Spanned<String>, ShellError>

Get current working directory

Source

fn add_env_var(&mut self, name: String, value: Value) -> Result<(), ShellError>

Set an environment variable

Source

fn get_help(&self) -> Result<Spanned<String>, ShellError>

Get help for the current command

Source

fn get_span_contents(&self, span: Span) -> Result<Spanned<Vec<u8>>, ShellError>

Get the contents of a Span

Source

fn eval_closure( &self, closure: Spanned<Closure>, positional: Vec<Value>, input: PipelineData, redirect_stdout: bool, redirect_stderr: bool, ) -> Result<PipelineData, ShellError>

Evaluate a closure passed to the plugin

Source

fn find_decl(&self, name: &str) -> Result<Option<DeclId>, ShellError>

Find a declaration by name

Source

fn call_decl( &mut self, decl_id: DeclId, call: EvaluatedCall, input: PipelineData, redirect_stdout: bool, redirect_stderr: bool, ) -> Result<PipelineData, ShellError>

Call a declaration with arguments and input

Source

fn boxed(&self) -> Box<dyn PluginExecutionContext>

Create an owned version of the context with 'static lifetime

Implementors§