pub trait QuicConnectionTrait:
Clone
+ Send
+ Sync
+ 'static {
type BidiStream: QuicTransportBidi + Unpin + Send + Sync + 'static;
type RecvStream: QuicTransportReceive + Unpin + Send + Sync + 'static;
type SendStream: QuicTransportSend + Unpin + Send + Sync + 'static;
// Required methods
fn accept_bidi(
&self,
) -> impl Future<Output = Result<(u64, Self::BidiStream)>> + Send;
fn accept_uni(
&self,
) -> impl Future<Output = Result<(u64, Self::RecvStream)>> + Send;
fn open_uni(
&self,
) -> impl Future<Output = Result<(u64, Self::SendStream)>> + Send;
fn open_bidi(
&self,
) -> impl Future<Output = Result<(u64, Self::BidiStream)>> + Send;
fn remote_address(&self) -> SocketAddr;
fn close(&self, error_code: u64, reason: &[u8]);
fn send_datagram(&self, data: &[u8]) -> Result<()>;
fn recv_datagram<F: FnOnce(&[u8]) + Send>(
&self,
callback: F,
) -> impl Future<Output = Result<()>> + Send;
fn max_datagram_size(&self) -> Option<usize>;
}Expand description
Abstraction over a single QUIC connection.
QUIC library adapters (e.g. trillium-quinn) implement this trait. The generic HTTP/3 connection handler in server-common consumes it to manage streams without knowing about the underlying QUIC implementation.
Implementations should be cheaply cloneable (typically wrapping an Arc-based connection
handle) since the connection handler clones this into spawned tasks.
Required Associated Types§
Sourcetype BidiStream: QuicTransportBidi + Unpin + Send + Sync + 'static
type BidiStream: QuicTransportBidi + Unpin + Send + Sync + 'static
A bidirectional stream
Sourcetype RecvStream: QuicTransportReceive + Unpin + Send + Sync + 'static
type RecvStream: QuicTransportReceive + Unpin + Send + Sync + 'static
A unidirectional receive stream from the peer
Sourcetype SendStream: QuicTransportSend + Unpin + Send + Sync + 'static
type SendStream: QuicTransportSend + Unpin + Send + Sync + 'static
A unidirectional send stream to the peer
Required Methods§
Sourcefn accept_bidi(
&self,
) -> impl Future<Output = Result<(u64, Self::BidiStream)>> + Send
fn accept_bidi( &self, ) -> impl Future<Output = Result<(u64, Self::BidiStream)>> + Send
Accept the next bidirectional stream opened by the peer.
Returns the QUIC stream ID and a combined read/write transport.
Sourcefn accept_uni(
&self,
) -> impl Future<Output = Result<(u64, Self::RecvStream)>> + Send
fn accept_uni( &self, ) -> impl Future<Output = Result<(u64, Self::RecvStream)>> + Send
Accept the next unidirectional stream opened by the peer.
Returns the QUIC stream ID and a receive-only stream.
Sourcefn open_uni(
&self,
) -> impl Future<Output = Result<(u64, Self::SendStream)>> + Send
fn open_uni( &self, ) -> impl Future<Output = Result<(u64, Self::SendStream)>> + Send
Open a new unidirectional stream to the peer.
Returns the QUIC stream ID and a send-only stream.
Sourcefn open_bidi(
&self,
) -> impl Future<Output = Result<(u64, Self::BidiStream)>> + Send
fn open_bidi( &self, ) -> impl Future<Output = Result<(u64, Self::BidiStream)>> + Send
Open a new bidirectional stream to the peer.
Returns the QUIC stream ID and a combined read/write transport.
Sourcefn remote_address(&self) -> SocketAddr
fn remote_address(&self) -> SocketAddr
The peer’s address.
Sourcefn close(&self, error_code: u64, reason: &[u8])
fn close(&self, error_code: u64, reason: &[u8])
Close the entire QUIC connection with an error code and reason.
Sourcefn send_datagram(&self, data: &[u8]) -> Result<()>
fn send_datagram(&self, data: &[u8]) -> Result<()>
Send an unreliable datagram over the QUIC connection.
Datagrams are atomic and unordered. The data must fit in a single QUIC packet (typically ~1200 bytes). Returns an error if datagrams are not supported by the peer or the data is too large.
Sourcefn recv_datagram<F: FnOnce(&[u8]) + Send>(
&self,
callback: F,
) -> impl Future<Output = Result<()>> + Send
fn recv_datagram<F: FnOnce(&[u8]) + Send>( &self, callback: F, ) -> impl Future<Output = Result<()>> + Send
Receive the next unreliable datagram from the peer, passing the raw bytes to callback.
Sourcefn max_datagram_size(&self) -> Option<usize>
fn max_datagram_size(&self) -> Option<usize>
The maximum datagram payload size the peer will accept, if datagrams are supported.
Returns None if the peer does not support datagrams.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.