ModuleHostAsync

Trait ModuleHostAsync 

Source
pub trait ModuleHostAsync {
    // Required methods
    fn get_guest_request<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Option<Invocation>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_host_response<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Option<Vec<u8>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn set_guest_error<'life0, 'async_trait>(
        &'life0 self,
        error: String,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn set_guest_response<'life0, 'async_trait>(
        &'life0 self,
        response: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_host_error<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn do_host_call<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        binding: &'life1 str,
        namespace: &'life2 str,
        operation: &'life3 str,
        payload: &'life4 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<i32, Box<dyn Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn do_console_log<'life0, 'life1, 'async_trait>(
        &'life0 self,
        msg: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Available on crate feature async only.
Expand description

The module host (waPC) must provide an implementation of this trait to the async engine provider to enable async waPC function calls.

Required Methods§

Source

fn get_guest_request<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<Invocation>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Called by the engine provider to obtain the Invocation bound for the guest module

Source

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

Called by the engine provider to query the results of a host function call

Source

fn set_guest_error<'life0, 'async_trait>( &'life0 self, error: String, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Called by the engine provider to set the error message indicating a failure that occurred inside the guest module execution

Source

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

Called by the engine provider to set the response data for a guest call

Source

fn get_host_error<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Called by the engine provider to query the host error if one is indicated by the return code for a host call

Source

fn do_host_call<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, binding: &'life1 str, namespace: &'life2 str, operation: &'life3 str, payload: &'life4 [u8], ) -> Pin<Box<dyn Future<Output = Result<i32, Box<dyn Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Called by the engine provider to allow a guest module to perform a host call. The numeric return value will be > 0 for success (engine must obtain the host response) or 0 for error (engine must obtain the error)

Source

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

Attempts to perform a console log. There are no guarantees this will happen, and no error will be returned to the guest module if the host rejects the attempt

Implementors§