xwt_web

Struct Session

Source
pub struct Session {
    pub transport: Rc<WebTransport>,
    pub datagram_readable_stream_reader: ReadableStreamByobReader,
    pub datagram_writable_stream_writer: WritableStreamDefaultWriter,
    pub datagram_read_buffer_size: u32,
    pub datagram_read_buffer: Mutex<Option<ArrayBuffer>>,
}
Expand description

Session holds the web_wt_sys::WebTransport and is responsible for providing access to the Web API of WebTransport in a way that is portable. It also holds handles to the datagram reader and writer, as well as the datagram reader state.

Fields§

§transport: Rc<WebTransport>

The WebTransport instance.

§datagram_readable_stream_reader: ReadableStreamByobReader

The datagram reader.

§datagram_writable_stream_writer: WritableStreamDefaultWriter

The datagram writer.

§datagram_read_buffer_size: u32

The desired size of the datagram read buffer. Used to allocate the datagram read buffer in case it gets lost.

§datagram_read_buffer: Mutex<Option<ArrayBuffer>>

The datagram read internal buffer.

Implementations§

Source§

impl Session

Source

pub async fn receive_datagram_with<R>( &self, f: impl FnOnce(&mut Uint8Array) -> R, ) -> Result<R, Error>

Receive the datagram and handle the buffer with the given function.

Cloning the buffer in the f will result in the undefined behaviour, because it will create a second reference to an object that is intended to be under a mut ref. Although is would not teachnically be unsafe, it would violate the borrow checker rules.

Trait Implementations§

Source§

impl AcceptBi for Session

Source§

type Error = Error

Source§

async fn accept_bi( &self, ) -> Result<(Self::SendStream, Self::RecvStream), Self::Error>

Source§

impl AcceptUni for Session

Source§

type Error = Error

Source§

async fn accept_uni(&self) -> Result<Self::RecvStream, Self::Error>

Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Session

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl MaxSize for Session

Source§

fn max_datagram_size(&self) -> Option<usize>

Gets the maximum byte length that a user-sent datagram is allowed to be. Read more
Source§

impl OpenBi for Session

Source§

impl OpenUni for Session

Source§

impl Receive for Session

Source§

impl ReceiveInto for Session

Source§

type Error = Error

Source§

async fn receive_datagram_into( &self, buf: &mut [u8], ) -> Result<usize, Self::Error>

Source§

impl RecvSpec for Session

Source§

impl Send for Session

Source§

type Error = Error

Source§

async fn send_datagram<D>(&self, payload: D) -> Result<(), Self::Error>
where D: AsRef<[u8]>,

Source§

impl SendSpec 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 UnwindSafe for Session

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Connection for T
where T: Session,

Source§

impl<T> DatagramOps for T
where T: Send + MaxSize + Send + Receive + ReceiveInto,

Source§

impl<T> PairSpec for T
where T: Send + SendSpec + RecvSpec,

Source§

impl<T> Send for T

Source§

impl<T> Session for T

Source§

impl<T> StreamOps for T

Source§

impl<T> Sync for T