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
impl Datagrams
Sourcepub fn from_transport(transport: &WebTransport) -> Self
pub fn from_transport(transport: &WebTransport) -> Self
Create a datagrams state from the transport.
Sourcepub fn from_transport_datagrams(
datagrams: &WebTransportDatagramDuplexStream,
) -> Self
pub fn from_transport_datagrams( datagrams: &WebTransportDatagramDuplexStream, ) -> Self
Create a datagrams state from the transport datagrams.
Source§impl Datagrams
impl Datagrams
Sourcepub async fn receive_with<R>(
&self,
max_read_size: Option<u32>,
f: impl FnOnce(&mut Uint8Array) -> R,
) -> Result<R, Error>
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§
Auto Trait Implementations§
impl !Freeze for Datagrams
impl !RefUnwindSafe for Datagrams
impl !Send for Datagrams
impl !Sync for Datagrams
impl Unpin for Datagrams
impl UnwindSafe for Datagrams
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