Skip to main content

CommandHandler

Trait CommandHandler 

Source
pub trait CommandHandler: Send + Sync {
    // Required method
    fn command(&self, command: Value) -> AnyResult<Value>;
}
Expand description

Command handler API exposed by connectors.

Connectors can support arbitrary connector-specific commands that can be invoked via the /command endpoint. These commands take and return arbitrary JSON values.

This API is not part of trait Output[Input]Endpoint because it can be invoked from any thread, and requires Send + Sync, while the OutputEndpoint API is not Sync and is meant to be called from the controller thread only.

The idea is that connectors that support custom commands create separate command handler objects that implement this trait and are returned by OutputEndpoint::command_handler.

Required Methods§

Source

fn command(&self, command: Value) -> AnyResult<Value>

Handle a command specified by the JSON objest.

Fails if the connector does not support the command, the command is invalid, or command execution fails.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§