Trait tower_lsp::jsonrpc::Method

source ·
pub trait Method<S, P, R>: Sealed {
    type Future: Future<Output = R> + Send;

    // Required method
    fn invoke(&self, server: S, params: P) -> Self::Future;
}
Expand description

A trait implemented by all valid JSON-RPC method handlers.

This trait abstracts over the following classes of functions and/or closures:

SignatureDescription
async fn f(&self) -> jsonrpc::Result<R>Request without parameters
async fn f(&self, params: P) -> jsonrpc::Result<R>Request with required parameters
async fn f(&self)Notification without parameters
async fn f(&self, params: P)Notification with parameters

Required Associated Types§

source

type Future: Future<Output = R> + Send

The future response value.

Required Methods§

source

fn invoke(&self, server: S, params: P) -> Self::Future

Invokes the method with the given server receiver and parameters.

Implementors§

source§

impl<F, S, P, R, Fut> Method<S, (P,), R> for F
where F: Fn(S, P) -> Fut, P: DeserializeOwned, Fut: Future<Output = R> + Send,

Support JSON-RPC methods with params.

§

type Future = Fut

source§

impl<F, S, R, Fut> Method<S, (), R> for F
where F: Fn(S) -> Fut, Fut: Future<Output = R> + Send,

Support parameter-less JSON-RPC methods.

§

type Future = Fut