diff --git a/tarpc/src/protocol/client.rs b/tarpc/src/protocol/client.rs index 0ac732f..5f86e61 100644 --- a/tarpc/src/protocol/client.rs +++ b/tarpc/src/protocol/client.rs @@ -18,8 +18,9 @@ use transport::{Dialer, Stream}; use transport::tcp::TcpDialer; /// A client stub that connects to a server to run rpcs. -pub struct Client - where Request: serde::ser::Serialize +pub struct Client + where Request: serde::ser::Serialize, + S: Stream, { // The guard is in an option so it can be joined in the drop fn reader_guard: Arc>>, @@ -40,9 +41,10 @@ impl Client } } -impl Client +impl Client where Request: serde::ser::Serialize + Send + 'static, - Reply: serde::de::Deserialize + Send + 'static + Reply: serde::de::Deserialize + Send + 'static, + S: Stream, { /// Create a new client that connects to `addr`. The client uses the given timeout /// for both reads and writes. @@ -107,8 +109,9 @@ impl Client } } -impl Drop for Client - where Request: serde::ser::Serialize +impl Drop for Client + where Request: serde::ser::Serialize, + S: Stream, { fn drop(&mut self) { debug!("Dropping Client."); @@ -195,11 +198,12 @@ impl RpcFutures { } } -fn write(outbound: Receiver<(Request, Sender>)>, +fn write(outbound: Receiver<(Request, Sender>)>, requests: Arc>>, stream: S) where Request: serde::Serialize, - Reply: serde::Deserialize + Reply: serde::Deserialize, + S: Stream, { let mut next_id = 0; let mut stream = BufWriter::new(stream); @@ -248,8 +252,9 @@ fn write(outbound: Receiver<(Request, Sender(requests: Arc>>, stream: S) - where Reply: serde::Deserialize +fn read(requests: Arc>>, stream: S) + where Reply: serde::Deserialize, + S: Stream, { let mut stream = BufReader::new(stream); loop {