Struct WebSocketConfig
struct WebSocketConfig { ... }
The configuration for WebSocket connection.
Example
# use WebSocketConfig;;
let conf = default
.read_buffer_size
.write_buffer_size;
Fields
read_buffer_size: usizeRead buffer capacity. This buffer is eagerly allocated and used for receiving messages.
For high read load scenarios a larger buffer, e.g. 128 KiB, improves performance.
For scenarios where you expect a lot of connections and don't need high read load performance a smaller buffer, e.g. 4 KiB, would be appropriate to lower total memory usage.
The default value is 128 KiB.
write_buffer_size: usizeThe target minimum size of the write buffer to reach before writing the data to the underlying stream. The default value is 128 KiB.
If set to
0each 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:
flushwill always fully write the buffer regardless.max_write_buffer_size: usizeThe 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. The default value is unlimited.
Note: The write buffer only builds up past
write_buffer_sizewhen writes to the underlying stream are failing. So the write buffer can not fill up if you are not observing write errors even if not flushing.Note: Should always be at least
write_buffer_size + 1 messageand probably a little more depending on error handling strategy.max_message_size: Option<usize>The maximum size of an incoming message.
Nonemeans no size limit. The default value is 64 MiB which should be reasonably big for all normal use-cases but small enough to prevent memory eating by a malicious user.max_frame_size: Option<usize>The maximum size of a single incoming message frame.
Nonemeans no size limit. The limit is for frame payload NOT including the frame header. The default value is 16 MiB which should be reasonably big for all normal use-cases but small enough to prevent memory eating by a malicious user.accept_unmasked_frames: boolWhen set to
true, the server will accept and handle unmasked frames from the client. According to the RFC 6455, the server must close the connection to the client in such cases, however it seems like there are some popular libraries that are sending unmasked frames, ignoring the RFC. By default this option is set tofalse, i.e. according to RFC 6455.
Implementations
impl WebSocketConfig
fn read_buffer_size(self: Self, read_buffer_size: usize) -> Selffn write_buffer_size(self: Self, write_buffer_size: usize) -> Selffn max_write_buffer_size(self: Self, max_write_buffer_size: usize) -> Selffn max_message_size(self: Self, max_message_size: Option<usize>) -> Selffn max_frame_size(self: Self, max_frame_size: Option<usize>) -> SelfSet
Self::max_frame_size.fn accept_unmasked_frames(self: Self, accept_unmasked_frames: bool) -> Self
impl Clone for WebSocketConfig
fn clone(self: &Self) -> WebSocketConfig
impl Copy for WebSocketConfig
impl Debug for WebSocketConfig
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Default for WebSocketConfig
fn default() -> Self
impl Freeze for WebSocketConfig
impl RefUnwindSafe for WebSocketConfig
impl Send for WebSocketConfig
impl Sync for WebSocketConfig
impl Unpin for WebSocketConfig
impl UnsafeUnpin for WebSocketConfig
impl UnwindSafe for WebSocketConfig
impl<T> Any for WebSocketConfig
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for WebSocketConfig
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for WebSocketConfig
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for WebSocketConfig
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for WebSocketConfig
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Same for WebSocketConfig
impl<T> ToOwned for WebSocketConfig
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for WebSocketConfig
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for WebSocketConfig
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for WebSocketConfig
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>
impl<V, T> VZip for WebSocketConfig
fn vzip(self: Self) -> V