Trait 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

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