diff options
Diffstat (limited to 'support/texlab/crates/jsonrpc/src/client.rs')
-rw-r--r-- | support/texlab/crates/jsonrpc/src/client.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/support/texlab/crates/jsonrpc/src/client.rs b/support/texlab/crates/jsonrpc/src/client.rs index 2cf18af1ff..7d714283c6 100644 --- a/support/texlab/crates/jsonrpc/src/client.rs +++ b/support/texlab/crates/jsonrpc/src/client.rs @@ -1,19 +1,22 @@ -use crate::types::*; +use super::types::*; +use async_trait::async_trait; use chashmap::CHashMap; -use futures::channel::*; -use futures::prelude::*; -use futures_boxed::boxed; +use futures::{ + channel::{mpsc, oneshot}, + prelude::*, +}; use serde::Serialize; use serde_json::json; use std::sync::atomic::{AtomicU64, Ordering}; pub type Result<T> = std::result::Result<T, Error>; +#[async_trait] pub trait ResponseHandler { - #[boxed] async fn handle(&self, response: Response); } +#[derive(Debug)] pub struct Client { output: mpsc::Sender<String>, request_id: AtomicU64, @@ -22,7 +25,7 @@ pub struct Client { impl Client { pub fn new(output: mpsc::Sender<String>) -> Self { - Client { + Self { output, request_id: AtomicU64::new(0), senders_by_id: CHashMap::new(), @@ -56,8 +59,8 @@ impl Client { } } +#[async_trait] impl ResponseHandler for Client { - #[boxed] async fn handle(&self, response: Response) { let id = response.id.expect("Expected response with id"); let result = match response.error { |