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. However, handles cannot currently accept or open the same stream type.
Implementations§
Source§impl Session
impl Session
pub fn new(inner: WebTransport, url: Url) -> Self
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.
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.
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§
Source§impl Session for Session
Available on target_family=wasm only.
impl Session for Session
Available on
target_family=wasm only.Source§type SendStream = SendStream
type SendStream = SendStream
Outgoing stream type returned by
open_* and accept_bi.Source§type RecvStream = RecvStream
type RecvStream = RecvStream
Incoming stream type returned by
accept_* and open_bi.Source§async fn accept_uni(&self) -> Result<Self::RecvStream, Self::Error>
async fn accept_uni(&self) -> Result<Self::RecvStream, Self::Error>
Block until the peer creates a new unidirectional stream.
Source§async fn accept_bi(
&self,
) -> Result<(Self::SendStream, Self::RecvStream), Self::Error>
async fn accept_bi( &self, ) -> Result<(Self::SendStream, Self::RecvStream), Self::Error>
Block until the peer creates a new bidirectional stream.
Source§async fn open_bi(
&self,
) -> Result<(Self::SendStream, Self::RecvStream), Self::Error>
async fn open_bi( &self, ) -> Result<(Self::SendStream, Self::RecvStream), Self::Error>
Open a new bidirectional stream, which may block if too many streams are open.
Source§async fn open_uni(&self) -> Result<Self::SendStream, Self::Error>
async fn open_uni(&self) -> Result<Self::SendStream, Self::Error>
Open a new unidirectional stream, which may block if too many streams are open.
Source§fn send_datagram(&self, payload: Bytes) -> Result<(), Self::Error>
fn send_datagram(&self, payload: Bytes) -> Result<(), Self::Error>
Send a datagram over the network. Read more
Source§async fn recv_datagram(&self) -> Result<Bytes, Self::Error>
async fn recv_datagram(&self) -> Result<Bytes, Self::Error>
Receive a datagram over the network.
Source§fn max_datagram_size(&self) -> usize
fn max_datagram_size(&self) -> usize
Return the maximum size of a datagram that can be sent.
impl Eq for Session
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin 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