Skip to main content

InvocationContext

Trait InvocationContext 

Source
pub trait InvocationContext: Send + Sync {
    // Required methods
    fn sql<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        config: &'life1 SurrealismConfig,
        query: String,
        vars: Object,
    ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn run<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        config: &'life1 SurrealismConfig,
        fnc: String,
        version: Option<String>,
        args: Vec<Value>,
    ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn kv(&mut self) -> Result<&dyn KVStore>;

    // Provided methods
    fn stdout(&mut self, output: &str) -> Result<()> { ... }
    fn stderr(&mut self, output: &str) -> Result<()> { ... }
    fn stdout_callback(&self) -> Arc<dyn Fn(&str) + Send + Sync>  { ... }
    fn stderr_callback(&self) -> Arc<dyn Fn(&str) + Send + Sync>  { ... }
}
Expand description

Context provided for each WASM function invocation. Created per-call with borrowed execution context (stack, query context, etc).

Required Methods§

Source

fn sql<'life0, 'life1, 'async_trait>( &'life0 mut self, config: &'life1 SurrealismConfig, query: String, vars: Object, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn run<'life0, 'life1, 'async_trait>( &'life0 mut self, config: &'life1 SurrealismConfig, fnc: String, version: Option<String>, args: Vec<Value>, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn kv(&mut self) -> Result<&dyn KVStore>

Provided Methods§

Source

fn stdout(&mut self, output: &str) -> Result<()>

Source

fn stderr(&mut self, output: &str) -> Result<()>

Source

fn stdout_callback(&self) -> Arc<dyn Fn(&str) + Send + Sync>

Returns a self-contained callback for forwarding WASI stdout output.

This is used by the WASI output stream to route guest println! / C printf output through the same path as the WIT stdout import. Override this to capture structured context (module name, namespace, database, etc.) inside the closure so the callback can be invoked independently of &mut self.

The returned Arc is cheap to clone and allows the WASI stream to snapshot the callback without holding a lock during invocation.

Source

fn stderr_callback(&self) -> Arc<dyn Fn(&str) + Send + Sync>

Same as stdout_callback but for stderr.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§