Skip to main content

BridgeHandler

Trait BridgeHandler 

Source
pub trait BridgeHandler: 'static {
    // Required method
    fn on_command(
        &self,
        name: Option<&str>,
        payload: &Value,
    ) -> Result<Value, String>;

    // Provided method
    fn on_event(&self, _name: &str, _data: &Value) { ... }
}

Required Methods§

Source

fn on_command( &self, name: Option<&str>, payload: &Value, ) -> Result<Value, String>

Handle a command (request/response). Must return a result.

name is the optional command name from the wire message. payload is the JSON payload.

Provided Methods§

Source

fn on_event(&self, _name: &str, _data: &Value)

Handle a fire-and-forget event from the host.

Default implementation does nothing. Override to process events.

Implementors§

Source§

impl BridgeHandler for Router

Source§

impl<F> BridgeHandler for F
where F: Fn(Option<&str>, &Value) -> Result<Value, String> + 'static,