pub struct Session { /* private fields */ }Expand description
A session represents a client-to-server connection.
This is the main entry point for creating streams and sending datagrams. Either endpoint may close the session with an error code and reason.
The session can be cloned to create multiple handles. Stream acceptance and datagram I/O are serialized across all clones because the browser exposes each incoming stream and datagram queue through a single Web Streams lock.
If an accept future is cancelled, the next accept call resumes the same pending browser read instead of losing the stream.
Implementations§
Source§impl Session
impl Session
pub fn new(inner: WebTransport, url: Url) -> Result<Self, Error>
Sourcepub async fn accept_uni(&self) -> Result<RecvStream, Error>
pub async fn accept_uni(&self) -> Result<RecvStream, Error>
Accept a new unidirectional stream from the peer.
Concurrent calls across cloned sessions are serviced in lock order. Cancelling a call does not discard a stream that arrives later.
Sourcepub async fn accept_bi(&self) -> Result<(SendStream, RecvStream), Error>
pub async fn accept_bi(&self) -> Result<(SendStream, RecvStream), Error>
Accept a new bidirectional stream from the peer.
Concurrent calls across cloned sessions are serviced in lock order. Cancelling a call does not discard a stream that arrives later.
Sourcepub async fn open_bi(&self) -> Result<(SendStream, RecvStream), Error>
pub async fn open_bi(&self) -> Result<(SendStream, RecvStream), Error>
Create a new bidirectional stream.
Sourcepub async fn open_uni(&self) -> Result<SendStream, Error>
pub async fn open_uni(&self) -> Result<SendStream, Error>
Create a new unidirectional stream.
Sourcepub async fn send_datagram(&self, payload: Bytes) -> Result<(), Error>
pub async fn send_datagram(&self, payload: Bytes) -> Result<(), Error>
Send a datagram over the network.
Sourcepub async fn recv_datagram(&self) -> Result<Bytes, Error>
pub async fn recv_datagram(&self) -> Result<Bytes, Error>
Receive a datagram over the network.
Trait Implementations§
impl Eq for Session
Source§impl Session for Session
Available on target_family=wasm only.
impl Session for Session
target_family=wasm only.Source§type SendStream = SendStream
type SendStream = SendStream
open_* and accept_bi.Source§type RecvStream = RecvStream
type RecvStream = RecvStream
accept_* and open_bi.