Session

Trait Session 

Source
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) -> Result<(), Self::Error>;
    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§

Required Methods§

Source

fn accept_uni( &self, ) -> impl Future<Output = Result<Self::RecvStream, Self::Error>> + MaybeSend

Block until the peer creates a new unidirectional stream.

Source

fn accept_bi( &self, ) -> impl Future<Output = Result<(Self::SendStream, Self::RecvStream), Self::Error>> + MaybeSend

Block until the peer creates a new bidirectional stream.

Source

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.

Source

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.

Source

fn send_datagram(&self, payload: Bytes) -> Result<(), Self::Error>

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.
Source

fn recv_datagram( &self, ) -> impl Future<Output = Result<Bytes, Self::Error>> + MaybeSend

Receive a datagram over the network.

Source

fn max_datagram_size(&self) -> usize

Return the maximum size of a datagram that can be sent.

Source

fn close(&self, code: u32, reason: &str)

Close the connection immediately with a code and reason.

Source

fn closed(&self) -> impl Future<Output = Self::Error> + MaybeSend

Block until the connection is closed by either side.

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.

Implementors§