From 78f68a6fa0a4004d68c1c901b45cf315cdf8187a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Michel?= Date: Mon, 10 Jul 2023 09:00:42 +0000 Subject: [PATCH] remove datagrams and use anyhow error type by default --- transport/src/lib.rs | 44 +++++++++++--------------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/transport/src/lib.rs b/transport/src/lib.rs index 19472dd..ab449c9 100644 --- a/transport/src/lib.rs +++ b/transport/src/lib.rs @@ -23,8 +23,6 @@ pub trait Connection { RecvStream = Self::RecvStream, BidiStream = Self::BidiStream, >; - /// Error type yielded by this trait methods - type Error: Into>; /// Accept an incoming unidirectional stream /// @@ -32,7 +30,7 @@ pub trait Connection { fn poll_accept_recv( &mut self, cx: &mut task::Context<'_>, - ) -> Poll, Self::Error>>; + ) -> Poll, Error>>; /// Accept an incoming bidirectional stream /// @@ -40,19 +38,19 @@ pub trait Connection { fn poll_accept_bidi( &mut self, cx: &mut task::Context<'_>, - ) -> Poll, Self::Error>>; + ) -> Poll, Error>>; /// Poll the connection to create a new bidirectional stream. fn poll_open_bidi( &mut self, cx: &mut task::Context<'_>, - ) -> Poll>; + ) -> Poll>; /// Poll the connection to create a new unidirectional stream. fn poll_open_send( &mut self, cx: &mut task::Context<'_>, - ) -> Poll>; + ) -> Poll>; /// Get an object to open outgoing streams. fn opener(&self) -> Self::OpenStreams; @@ -61,22 +59,6 @@ pub trait Connection { fn close(&mut self, code: ErrorCode, reason: &[u8]); } -/// Extends the `Connection` trait for receiving datagrams -/// -/// See: -pub trait RecvDatagramExt { - /// The type of `Buf` for *raw* datagrams (without the stream_id decoded) - type Buf: Buf; - /// The error type that can occur when receiving a datagram - type Error: Into>; - - /// Poll the connection for incoming datagrams. - fn poll_accept_datagram( - &mut self, - cx: &mut task::Context<'_>, - ) -> Poll, Self::Error>>; -} - /// Trait for opening outgoing streams pub trait OpenStreams { /// The type produced by `poll_open_bidi()` @@ -85,20 +67,18 @@ pub trait OpenStreams { type SendStream: SendStream; /// The type of the receiving part of `BidiStream` type RecvStream: RecvStream; - /// Error type yielded by these trait methods - type Error: Into>; /// Poll the connection to create a new bidirectional stream. fn poll_open_bidi( &mut self, cx: &mut task::Context<'_>, - ) -> Poll>; + ) -> Poll>; /// Poll the connection to create a new unidirectional stream. fn poll_open_send( &mut self, cx: &mut task::Context<'_>, - ) -> Poll>; + ) -> Poll>; /// Close the connection immediately fn close(&mut self, code: ErrorCode, reason: &[u8]); @@ -106,17 +86,15 @@ pub trait OpenStreams { /// A trait describing the "send" actions of a QUIC stream. pub trait SendStream { - /// The error type returned by fallible send methods. - type Error: Into>; /// Polls if the stream can send more data. - fn poll_ready(&mut self, cx: &mut task::Context<'_>) -> Poll>; + fn poll_ready(&mut self, cx: &mut task::Context<'_>) -> Poll>; /// Send more data on the stream. - fn send_data(&mut self, data: T) -> Result<(), Self::Error>; + fn send_data(&mut self, data: T) -> Result<(), Error>; /// Poll to finish the sending side of the stream. - fn poll_finish(&mut self, cx: &mut task::Context<'_>) -> Poll>; + fn poll_finish(&mut self, cx: &mut task::Context<'_>) -> Poll>; /// Send a QUIC reset code. fn reset(&mut self, reset_code: u64); @@ -136,7 +114,7 @@ pub trait SendStreamUnframed: SendStream { &mut self, cx: &mut task::Context<'_>, buf: &mut D, - ) -> Poll>; + ) -> Poll>; } /// A trait describing the "receive" actions of a QUIC stream. @@ -153,7 +131,7 @@ pub trait RecvStream { fn poll_data( &mut self, cx: &mut task::Context<'_>, - ) -> Poll, Self::Error>>; + ) -> Poll, Error>>; /// Send a `STOP_SENDING` QUIC code. fn stop_sending(&mut self, error_code: u64);