Struct web_transport::Session
source · pub struct Session(/* private fields */);
Expand description
A WebTransport Session, able to accept/create streams and send/recv datagrams.
The session can be cloned to create multiple handles. The session will be closed with on drop.
Implementations§
source§impl Session
impl Session
sourcepub async fn accept_uni(&mut self) -> Result<RecvStream, SessionError>
pub async fn accept_uni(&mut self) -> Result<RecvStream, SessionError>
Block until the peer creates a new unidirectional stream.
sourcepub async fn accept_bi(
&mut self,
) -> Result<(SendStream, RecvStream), SessionError>
pub async fn accept_bi( &mut self, ) -> Result<(SendStream, RecvStream), SessionError>
Block until the peer creates a new bidirectional stream.
sourcepub async fn open_bi(
&mut self,
) -> Result<(SendStream, RecvStream), SessionError>
pub async fn open_bi( &mut self, ) -> Result<(SendStream, RecvStream), SessionError>
Open a new bidirectional stream, which may block when there are too many concurrent streams.
sourcepub async fn open_uni(&mut self) -> Result<SendStream, SessionError>
pub async fn open_uni(&mut self) -> Result<SendStream, SessionError>
Open a new unidirectional stream, which may block when there are too many concurrent streams.
sourcepub async fn send_datagram(
&mut self,
payload: Bytes,
) -> Result<(), SessionError>
pub async fn send_datagram( &mut self, payload: Bytes, ) -> Result<(), SessionError>
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.
- ???
sourcepub async fn max_datagram_size(&self) -> usize
pub async fn max_datagram_size(&self) -> usize
The maximum size of a datagram that can be sent.
sourcepub async fn recv_datagram(&mut self) -> Result<Bytes, SessionError>
pub async fn recv_datagram(&mut self) -> Result<Bytes, SessionError>
Receive a datagram over the network.
sourcepub fn close(self, code: u32, reason: &str)
pub fn close(self, code: u32, reason: &str)
Close the connection immediately with a code and reason.
sourcepub async fn closed(&self) -> SessionError
pub async fn closed(&self) -> SessionError
Block until the connection is closed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnwindSafe for Session
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)