Skip to main content

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,
    ) -> 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§

Source

type SendStream: SendStream

Outgoing stream type returned by open_* and accept_bi.

Source

type RecvStream: RecvStream

Incoming stream type returned by accept_* and open_bi.

Source

type Error: Error

Error type returned by session operations.

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, ) -> 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.
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".

Implementors§