pub trait Session:
Clone
+ MaybeSend
+ MaybeSync
+ 'static {
type SendStream: SendStream;
type RecvStream: RecvStream;
type Error: Error;
// Required methods
fn accept_uni(
&self,
) -> impl Future<Output = Result<Self::RecvStream, Self::Error>> + MaybeSend;
fn accept_bi(
&self,
) -> impl Future<Output = Result<(Self::SendStream, Self::RecvStream), Self::Error>> + MaybeSend;
fn open_bi(
&self,
) -> impl Future<Output = Result<(Self::SendStream, Self::RecvStream), Self::Error>> + MaybeSend;
fn open_uni(
&self,
) -> impl Future<Output = Result<Self::SendStream, Self::Error>> + MaybeSend;
fn send_datagram(
&self,
payload: Bytes,
) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend;
fn recv_datagram(
&self,
) -> impl Future<Output = Result<Bytes, Self::Error>> + MaybeSend;
fn max_datagram_size(&self) -> usize;
fn close(&self, code: u32, reason: &str);
fn closed(&self) -> impl Future<Output = Self::Error> + MaybeSend;
}Expand description
A WebTransport session that can accept/create streams and send/receive datagrams.
The session can be cloned to create multiple handles. The session will be closed on drop.
Required Associated Types§
Sourcetype SendStream: SendStream
type SendStream: SendStream
Outgoing stream type returned by open_* and accept_bi.
Sourcetype RecvStream: RecvStream
type RecvStream: RecvStream
Incoming stream type returned by accept_* and open_bi.
Required Methods§
Sourcefn accept_uni(
&self,
) -> impl Future<Output = Result<Self::RecvStream, Self::Error>> + MaybeSend
fn accept_uni( &self, ) -> impl Future<Output = Result<Self::RecvStream, Self::Error>> + MaybeSend
Block until the peer creates a new unidirectional stream.
Sourcefn accept_bi(
&self,
) -> impl Future<Output = Result<(Self::SendStream, Self::RecvStream), Self::Error>> + MaybeSend
fn accept_bi( &self, ) -> impl Future<Output = Result<(Self::SendStream, Self::RecvStream), Self::Error>> + MaybeSend
Block until the peer creates a new bidirectional stream.
Sourcefn open_bi(
&self,
) -> impl Future<Output = Result<(Self::SendStream, Self::RecvStream), Self::Error>> + MaybeSend
fn open_bi( &self, ) -> impl Future<Output = Result<(Self::SendStream, Self::RecvStream), Self::Error>> + MaybeSend
Open a new bidirectional stream, which may block if too many streams are open.
Sourcefn open_uni(
&self,
) -> impl Future<Output = Result<Self::SendStream, Self::Error>> + MaybeSend
fn open_uni( &self, ) -> impl Future<Output = Result<Self::SendStream, Self::Error>> + MaybeSend
Open a new unidirectional stream, which may block if too many streams are open.
Sourcefn send_datagram(
&self,
payload: Bytes,
) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend
fn send_datagram( &self, payload: Bytes, ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend
Send a datagram over the network.
QUIC datagrams may be dropped for any reason:
- Network congestion.
- Random packet loss.
- Payload is larger than
max_datagram_size(). - Peer is not receiving datagrams.
- Peer has too many outstanding datagrams.
- Implementation-specific limits.
Sourcefn recv_datagram(
&self,
) -> impl Future<Output = Result<Bytes, Self::Error>> + MaybeSend
fn recv_datagram( &self, ) -> impl Future<Output = Result<Bytes, Self::Error>> + MaybeSend
Receive a datagram over the network.
Sourcefn max_datagram_size(&self) -> usize
fn max_datagram_size(&self) -> usize
Return the maximum size of a datagram that can be sent.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".