pub struct WebSocketConnection { /* private fields */ }Expand description
Represents the extractor for establishing WebSockets connections
Implementations§
Source§impl WebSocketConnection
impl WebSocketConnection
Sourcepub fn with_read_buffer_size(self, size: usize) -> Self
pub fn with_read_buffer_size(self, size: usize) -> Self
Sets the read buffer capacity.
Default: 128KiB
Sourcepub fn with_write_buffer_size(self, size: usize) -> Self
pub fn with_write_buffer_size(self, size: usize) -> Self
Sets the target minimum size of the write buffer to reach before writing the data to the underlying stream.
Default: 128 KiB.
If set to 0 each message will be eagerly written to the underlying stream.
It is often more optimal to allow them to buffer a little, hence the default value.
Note: flush will always fully write the buffer regardless.
Sourcepub fn with_max_write_buffer_size(self, max: usize) -> Self
pub fn with_max_write_buffer_size(self, max: usize) -> Self
Sets the max size of the write buffer in bytes. Setting this can provide backpressure in the case the write buffer is filling up due to write errors.
Default: not set/unlimited
Note: The write buffer only builds up past write_buffer_size
when writes to the underlying stream are failing. So the write buffer cannot
fill up if you are not observing write errors even if not flushing.
Note: Should always be at least write_buffer_size + 1 message
and probably a little more depending on error handling strategy.
Sourcepub fn with_max_message_size(self, max: usize) -> Self
pub fn with_max_message_size(self, max: usize) -> Self
Sets the maximum message size
Default: 64 MiB
Sourcepub fn with_max_frame_size(self, max: usize) -> Self
pub fn with_max_frame_size(self, max: usize) -> Self
Sets the maximum frame size
Default: 16 MiB
Sourcepub fn with_accept_unmasked_frames(self, accept: bool) -> Self
pub fn with_accept_unmasked_frames(self, accept: bool) -> Self
Sets/unsets a web-server to accept unmasked frames
Default: false
Sourcepub fn with_protocols<const N: usize>(self, known: [&'static str; N]) -> Self
pub fn with_protocols<const N: usize>(self, known: [&'static str; N]) -> Self
Sets the protocols known by the server.
Default: empty list