Skip to main content

IsolatedContext

Trait IsolatedContext 

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

Source

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.

Source

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.

Source

fn set_global(&mut self, name: &str, value: Value) -> PluginResult<()>

Set a global variable in this context.

Source

fn get_global(&self, name: &str) -> PluginResult<Value>

Get a global variable from this context.

Implementors§