Trait tokio_jsonrpc::server::Server [] [src]

pub trait Server {
    type Success: Serialize;
    type RpcCallResult: IntoFuture<Item=Self::Success, Error=RpcError> + 'static;
    type NotificationResult: IntoFuture<Item=(), Error=()> + 'static;
    fn rpc(&self,
           _ctl: &ServerCtl,
           _method: &str,
           _params: &Option<Value>)
           -> Option<Self::RpcCallResult> { ... } fn notification(&self,
                    _ctl: &ServerCtl,
                    _method: &str,
                    _params: &Option<Value>)
                    -> Option<Self::NotificationResult> { ... } fn initialized(&self, _ctl: &ServerCtl) { ... } }

The server endpoint.

This is usually implemented by the end application and provides the actual functionality of the RPC server. It allows composition of more servers together.

The default implementations of the callbacks return None, indicating that the given method is not known. It allows implementing only RPCs or only notifications without having to worry about the other callback. If you want a server that does nothing at all, use Empty.

Associated Types

The successfull result of the RPC call.

The result of the RPC call

Once the future resolves, the value or error is sent to the client as the reply. The reply is wrapped automatically.

The result of the RPC call.

As the client doesn't expect anything in return, both the success and error results are thrown away and therefore (). However, it still makes sense to distinguish success and error.

Provided Methods

Called when the client requests something.

This is a callback from the endpoint when the client requests something. If the method is unknown, it shall return None. This allows composition of servers.

Conversion of parameters and handling of errors is up to the implementer of this trait. However, the jsonrpc_params macro may help in that regard.

Called when the client sends a notification.

This is a callback from the endpoint when the client requests something. If the method is unknown, it shall return None. This allows composition of servers.

Conversion of parameters and handling of errors is up to the implementer of this trait. However, the jsonrpc_params macro may help in that regard.

Called when the endpoint is initialized.

It provides a default empty implementation, which can be overriden to hook onto the initialization.

Implementors