diff --git a/src/connection/async_tokio.rs b/src/connection/async_tokio.rs index 7a22d67..edc422d 100644 --- a/src/connection/async_tokio.rs +++ b/src/connection/async_tokio.rs @@ -109,6 +109,12 @@ impl Connection { } } + /// Shorthand for calling [`send`] and [`receive`] after one another. + pub async fn send_and_receive<'de, A, B>(&mut self, data: &A) -> Result where A: Serialize, B: Deserialize<'de> { + self.send(data).await?; + self.receive().await + } + async fn _close(&mut self) { self.internal.close().await; self.closed = true; diff --git a/src/connection/sync.rs b/src/connection/sync.rs index 816f643..db4d167 100644 --- a/src/connection/sync.rs +++ b/src/connection/sync.rs @@ -118,7 +118,7 @@ impl Connection { } } /// Shorthand for calling [`send`](Self::send) and [`receive`](Self::receive) after one another. - pub fn send_and_receive<'de, A, B>(&mut self, data: &A) -> Result> where A: Serialize, B: Deserialize<'de> { + pub fn send_and_receive<'de, A, B>(&mut self, data: &A) -> Result where A: Serialize, B: Deserialize<'de> { self.send(data)?; self.receive() }