Struct xwt_web_sys::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 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, becaue it will create a second reference to an object that is inteded to be under a mut ref. Althoug is would not teachnically be unsafe, it would violate the borrow checker rules.

Trait Implementations§

source§

impl AcceptBi for Session

§

type Error = Error

source§

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

source§

impl AcceptUni for Session

§

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 OpenBi for Session

§

type Opening = OpeningBiStream<Session>

§

type Error = Error

source§

async fn open_bi(&self) -> Result<Self::Opening, Self::Error>

source§

impl OpenUni for Session

§

type Opening = OpeningUniStream<Session>

§

type Error = Error

source§

async fn open_uni(&self) -> Result<Self::Opening, Self::Error>

source§

impl Receive for Session

§

type Datagram = Vec<u8>

§

type Error = Error

source§

async fn receive_datagram(&self) -> Result<Self::Datagram, Self::Error>

source§

impl ReceiveInto for Session

§

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

§

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

§

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

§

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 + 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