pub trait IsolatedContext: Send {
// Required methods
fn execute<'a>(
&'a self,
code: &'a [u8],
cancel: CancellationToken,
) -> Pin<Box<dyn Future<Output = PluginResult<Value>> + Send + 'a>>;
fn call_function<'a>(
&'a self,
name: &'a str,
args: Vec<Value>,
cancel: CancellationToken,
) -> Pin<Box<dyn Future<Output = PluginResult<Value>> + Send + 'a>>;
fn set_global(&mut self, name: &str, value: Value) -> PluginResult<()>;
fn get_global(&self, name: &str) -> PluginResult<Value>;
}Expand description
An isolated execution context for running plugin code safely.
Isolated contexts are used for async plugins (previewers, analyzers) that run in background tasks. They have:
- Their own script state (not shared with main runtime)
- Limited API access (no UI modification)
- Cancellation support
- Resource limits
Required Methods§
Sourcefn execute<'a>(
&'a self,
code: &'a [u8],
cancel: CancellationToken,
) -> Pin<Box<dyn Future<Output = PluginResult<Value>> + Send + 'a>>
fn execute<'a>( &'a self, code: &'a [u8], cancel: CancellationToken, ) -> Pin<Box<dyn Future<Output = PluginResult<Value>> + Send + 'a>>
Execute a chunk of code in this isolated context.
Sourcefn call_function<'a>(
&'a self,
name: &'a str,
args: Vec<Value>,
cancel: CancellationToken,
) -> Pin<Box<dyn Future<Output = PluginResult<Value>> + Send + 'a>>
fn call_function<'a>( &'a self, name: &'a str, args: Vec<Value>, cancel: CancellationToken, ) -> Pin<Box<dyn Future<Output = PluginResult<Value>> + Send + 'a>>
Execute a named function with arguments.
Sourcefn set_global(&mut self, name: &str, value: Value) -> PluginResult<()>
fn set_global(&mut self, name: &str, value: Value) -> PluginResult<()>
Set a global variable in this context.
Sourcefn get_global(&self, name: &str) -> PluginResult<Value>
fn get_global(&self, name: &str) -> PluginResult<Value>
Get a global variable from this context.