Trait wapc::ModuleHost
source · pub trait ModuleHost {
// Required methods
fn get_guest_request(&self) -> Option<Invocation>;
fn get_host_response(&self) -> Option<Vec<u8>>;
fn set_guest_error(&self, error: String);
fn set_guest_response(&self, response: Vec<u8>);
fn get_host_error(&self) -> Option<String>;
fn do_host_call(
&self,
binding: &str,
namespace: &str,
operation: &str,
payload: &[u8]
) -> Result<i32, Box<dyn Error>>;
fn do_console_log(&self, msg: &str);
}
Expand description
The module host (waPC) must provide an implementation of this trait to the engine provider to enable waPC function calls.
Required Methods§
sourcefn get_guest_request(&self) -> Option<Invocation>
fn get_guest_request(&self) -> Option<Invocation>
Called by the engine provider to obtain the Invocation bound for the guest module
sourcefn get_host_response(&self) -> Option<Vec<u8>>
fn get_host_response(&self) -> Option<Vec<u8>>
Called by the engine provider to query the results of a host function call
sourcefn set_guest_error(&self, error: String)
fn set_guest_error(&self, error: String)
Called by the engine provider to set the error message indicating a failure that occurred inside the guest module execution
sourcefn set_guest_response(&self, response: Vec<u8>)
fn set_guest_response(&self, response: Vec<u8>)
Called by the engine provider to set the response data for a guest call
sourcefn get_host_error(&self) -> Option<String>
fn get_host_error(&self) -> Option<String>
Called by the engine provider to query the host error if one is indicated by the return code for a host call
sourcefn do_host_call(
&self,
binding: &str,
namespace: &str,
operation: &str,
payload: &[u8]
) -> Result<i32, Box<dyn Error>>
fn do_host_call( &self, binding: &str, namespace: &str, operation: &str, payload: &[u8] ) -> Result<i32, Box<dyn Error>>
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)
sourcefn do_console_log(&self, msg: &str)
fn do_console_log(&self, msg: &str)
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