Trait nvim_rs::rpc::handler::Handler

source ·
pub trait Handler: Send + Sync + Clone + 'static {
    type Writer: AsyncWrite + Send + Unpin + 'static;

    // Provided methods
    fn handle_request<'life0, 'async_trait>(
        &'life0 self,
        _name: String,
        _args: Vec<Value>,
        _neovim: Neovim<Self::Writer>
    ) -> Pin<Box<dyn Future<Output = Result<Value, Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn handle_notify<'life0, 'async_trait>(
        &'life0 self,
        _name: String,
        _args: Vec<Value>,
        _neovim: Neovim<<Self as Handler>::Writer>
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

The central functionality of a plugin. The trait bounds asure that each asynchronous task can receive a copy of the handler, so some state can be shared.

Required Associated Types§

source

type Writer: AsyncWrite + Send + Unpin + 'static

The type where we write our responses to requests. Handling of incoming requests/notifications is done on the io loop, which passes the parsed messages to the handler.

Provided Methods§

source

fn handle_request<'life0, 'async_trait>( &'life0 self, _name: String, _args: Vec<Value>, _neovim: Neovim<Self::Writer> ) -> Pin<Box<dyn Future<Output = Result<Value, Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handling an rpc request. The ID’s of requests are handled by the neovim instance.

source

fn handle_notify<'life0, 'async_trait>( &'life0 self, _name: String, _args: Vec<Value>, _neovim: Neovim<<Self as Handler>::Writer> ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handling an rpc notification. Notifications are handled one at a time in the order in which they were received, and will block new requests from being received until handle_notify returns.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<Q> Handler for Dummy<Q>
where Q: AsyncWrite + Send + Sync + Unpin + 'static,

§

type Writer = Q