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
impl Session
sourcepub async fn receive_datagram_with<R>(
&self,
f: impl FnOnce(&mut Uint8Array) -> R
) -> Result<R, Error>
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.