[][src]Trait waxosuit_codec::capabilities::CapabilityProvider

pub trait CapabilityProvider: Any + Send + Sync {
    fn configure_dispatch(
        &self,
        dispatcher: Box<dyn Dispatcher>,
        identity: ModuleIdentity
    ) -> Result<(), Box<dyn Error>>;
fn capability_id(&self) -> &'static str;
fn name(&self) -> &'static str;
fn handle_call(
        &self,
        op: &str,
        msg: &[u8]
    ) -> Result<Vec<u8>, Box<dyn Error>>; }

Every capability provider must implement this trait

Required methods

fn configure_dispatch(
    &self,
    dispatcher: Box<dyn Dispatcher>,
    identity: ModuleIdentity
) -> Result<(), Box<dyn Error>>

This function will be called on the provider when the host runtime is ready and has configured a dispatcher

fn capability_id(&self) -> &'static str

The capability provider will return either one of the well-known capability IDs or a custom capability ID using category:id notation

fn name(&self) -> &'static str

The human-readable, friendly name of this capability provider. By convention, the provider should include its specific implementation, .e.g. include "Redis" in the name for a Redis-based capability provider.

fn handle_call(&self, op: &str, msg: &[u8]) -> Result<Vec<u8>, Box<dyn Error>>

This function is called by the host runtime when a guest module is requesting a command be executed by the capability provider

Loading content...

Implementors

Loading content...