Datagrams

Struct Datagrams 

Source
pub struct Datagrams {
    pub readable_stream_reader: ReadableStreamByobReader,
    pub writable_stream_writer: WritableStreamDefaultWriter,
    pub read_buffer_size: u32,
    pub read_buffer: Mutex<Option<ArrayBuffer>>,
    pub unlock_streams_on_drop: bool,
}
Expand description

Datagrams hold the portions of the session that are responsible for working with the datagrams.

Fields§

§readable_stream_reader: ReadableStreamByobReader

The datagram reader.

§writable_stream_writer: WritableStreamDefaultWriter

The datagram writer.

§read_buffer_size: u32

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

§read_buffer: Mutex<Option<ArrayBuffer>>

The datagram read internal buffer.

§unlock_streams_on_drop: bool

Unlock the streams on drop.

Implementations§

Source§

impl Datagrams

Source

pub fn from_transport(transport: &WebTransport) -> Self

Create a datagrams state from the transport.

Source

pub fn from_transport_datagrams( datagrams: &WebTransportDatagramDuplexStream, ) -> Self

Create a datagrams state from the transport datagrams.

Source§

impl Datagrams

Source

pub async fn receive_with<R>( &self, max_read_size: Option<u32>, 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 Debug for Datagrams

Source§

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

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

impl Drop for Datagrams

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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> Send for T

Source§

impl<T> Sync for T