From 9f690f7f009201b320c88886e5416eef6767ebcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Michel?= Date: Tue, 11 Jul 2023 11:51:16 +0000 Subject: [PATCH] update transport trait --- transport/src/lib.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/transport/src/lib.rs b/transport/src/lib.rs index cc35615..f2de12a 100644 --- a/transport/src/lib.rs +++ b/transport/src/lib.rs @@ -91,7 +91,7 @@ pub trait SendStream { } /// Allows sending unframed pure bytes to a stream. Similar to [`AsyncWrite`](https://docs.rs/tokio/latest/tokio/io/trait.AsyncWrite.html) -pub trait SendStreamUnframed: SendStream { +pub trait SendStreamUnframed: SendStream { /// Attempts write data into the stream. /// /// Returns the number of bytes written. @@ -108,8 +108,6 @@ pub trait SendStreamUnframed: SendStream { pub trait RecvStream { /// The type of `Buf` for data received on this stream. type Buf: Buf; - /// The error type that can occur when receiving data. - type Error: Into>; /// Poll the stream for more data. /// @@ -118,7 +116,7 @@ pub trait RecvStream { fn poll_data( &mut self, cx: &mut task::Context<'_>, - ) -> Poll, Error>>; + ) -> Poll, anyhow::Error>>; /// Send a `STOP_SENDING` QUIC code. fn stop_sending(&mut self, error_code: u64); @@ -128,29 +126,29 @@ pub trait RecvStream { } -pub async fn accept_recv, R: RecvStream>(conn: &mut C) -> anyhow::Result, Error> { +pub async fn accept_recv(conn: &mut C) -> anyhow::Result, Error> { Ok(std::future::poll_fn(|cx| conn.poll_accept_recv(cx)).await?) } -pub async fn accept_bidi, B: BidiStream>(conn: &mut C) -> anyhow::Result, Error> { +pub async fn accept_bidi(conn: &mut C) -> anyhow::Result, Error> { Ok(std::future::poll_fn(|cx| conn.poll_accept_bidi(cx)).await?) } -pub async fn open_send, S: SendStream>(conn: &mut C) -> anyhow::Result { +pub async fn open_send(conn: &mut C) -> anyhow::Result { Ok(std::future::poll_fn(|cx| conn.poll_open_send(cx)).await?) } -pub async fn open_bidi, B: BidiStream>(conn: &mut C) -> anyhow::Result { +pub async fn open_bidi(conn: &mut C) -> anyhow::Result { Ok(std::future::poll_fn(|cx| conn.poll_open_bidi(cx)).await?) } -pub async fn recv>(recv: &mut R , outbuf: &mut BM) -> anyhow::Result { +pub async fn recv>(recv: &mut R , outbuf: &mut BM) -> anyhow::Result { let buf = std::future::poll_fn(|cx| recv.poll_data(cx)).await?; match buf { Some(buf) => { @@ -161,7 +159,7 @@ pub async fn recv>(send: &mut S, buf: &mut B) -> anyhow::Result { +pub async fn send(send: &mut S, buf: &mut B) -> anyhow::Result { Ok(std::future::poll_fn(|cx| send.poll_send(cx, buf)).await?) }