Skip to main content

HostFunctions

Trait HostFunctions 

Source
pub trait HostFunctions: Send + Sync {
    // Required methods
    fn log<'life0, 'life1, 'async_trait>(
        &'life0 self,
        level: LogLevel,
        message: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = WasmResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_config<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = WasmResult<Option<WasmValue>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn set_config<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        value: WasmValue,
    ) -> Pin<Box<dyn Future<Output = WasmResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn send_message<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        target: &'life1 str,
        payload: &'life2 [u8],
    ) -> Pin<Box<dyn Future<Output = WasmResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn call_tool<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tool_name: &'life1 str,
        args: WasmValue,
    ) -> Pin<Box<dyn Future<Output = WasmResult<WasmValue>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn storage_get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = WasmResult<Option<Vec<u8>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn storage_set<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        value: &'life2 [u8],
    ) -> Pin<Box<dyn Future<Output = WasmResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn storage_delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = WasmResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn now_ms<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = WasmResult<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn random_bytes<'life0, 'async_trait>(
        &'life0 self,
        len: u32,
    ) -> Pin<Box<dyn Future<Output = WasmResult<Vec<u8>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn sleep_ms<'life0, 'async_trait>(
        &'life0 self,
        ms: u64,
    ) -> Pin<Box<dyn Future<Output = WasmResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn call_custom<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
        args: Vec<WasmValue>,
    ) -> Pin<Box<dyn Future<Output = WasmResult<WasmValue>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Host functions interface that plugins can call

Required Methods§

Source

fn log<'life0, 'life1, 'async_trait>( &'life0 self, level: LogLevel, message: &'life1 str, ) -> Pin<Box<dyn Future<Output = WasmResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Log a message

Source

fn get_config<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = WasmResult<Option<WasmValue>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get configuration value

Source

fn set_config<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, value: WasmValue, ) -> Pin<Box<dyn Future<Output = WasmResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Set configuration value (requires WriteConfig capability)

Source

fn send_message<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, target: &'life1 str, payload: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = WasmResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Send a message to another agent/plugin

Source

fn call_tool<'life0, 'life1, 'async_trait>( &'life0 self, tool_name: &'life1 str, args: WasmValue, ) -> Pin<Box<dyn Future<Output = WasmResult<WasmValue>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Call a tool

Source

fn storage_get<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = WasmResult<Option<Vec<u8>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get from storage

Source

fn storage_set<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 str, value: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = WasmResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Set in storage

Source

fn storage_delete<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = WasmResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete from storage

Source

fn now_ms<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = WasmResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get current timestamp (milliseconds)

Source

fn random_bytes<'life0, 'async_trait>( &'life0 self, len: u32, ) -> Pin<Box<dyn Future<Output = WasmResult<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Generate random bytes

Source

fn sleep_ms<'life0, 'async_trait>( &'life0 self, ms: u64, ) -> Pin<Box<dyn Future<Output = WasmResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sleep for specified milliseconds

Source

fn call_custom<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, args: Vec<WasmValue>, ) -> Pin<Box<dyn Future<Output = WasmResult<WasmValue>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Call a custom host function

Implementors§