pub struct Settings {
Show 25 fields pub max_connections: usize, pub queue_size: usize, pub panic_on_new_connection: bool, pub panic_on_shutdown: bool, pub fragments_capacity: usize, pub fragments_grow: bool, pub fragment_size: usize, pub max_fragment_size: usize, pub in_buffer_capacity: usize, pub max_in_buffer_capacity: usize, pub out_buffer_capacity: usize, pub max_out_buffer_capacity: usize, pub panic_on_internal: bool, pub panic_on_capacity: bool, pub panic_on_protocol: bool, pub panic_on_encoding: bool, pub panic_on_queue: bool, pub panic_on_io: bool, pub panic_on_timeout: bool, pub shutdown_on_interrupt: bool, pub masking_strict: bool, pub key_strict: bool, pub method_strict: bool, pub encrypt_server: bool, pub tcp_nodelay: bool,
}
Expand description

WebSocket settings

Fields

max_connections: usize

The maximum number of connections that this WebSocket will support. The default setting is low and should be increased when expecting more connections because this is a hard limit and no new connections beyond this limit can be made until an old connection is dropped. Default: 100

queue_size: usize

The number of events anticipated per connection. The event loop queue size will be queue_size * max_connections. In order to avoid an overflow error, queue_size * max_connections must be less than or equal to usize::max_value(). The queue is shared between connections, which means that a connection may schedule more events than queue_size provided that another connection is using less than queue_size. However, if the queue is maxed out a Queue error will occur. Default: 5

panic_on_new_connection: bool

Whether to panic when unable to establish a new TCP connection. Default: false

panic_on_shutdown: bool

Whether to panic when a shutdown of the WebSocket is requested. Default: false

fragments_capacity: usize

The maximum number of fragments the connection can handle without reallocating. Default: 10

fragments_grow: bool

Whether to reallocate when fragments_capacity is reached. If this is false, a Capacity error will be triggered instead. Default: true

fragment_size: usize

The maximum length of outgoing frames. Messages longer than this will be fragmented. Default: 65,535

max_fragment_size: usize

The maximum length of acceptable incoming frames. Messages longer than this will be rejected. Default: unlimited

in_buffer_capacity: usize

The initial size of the incoming buffer. A larger buffer uses more memory but will allow for fewer reallocations. Default: 2048

max_in_buffer_capacity: usize

The maximum size to which the incoming buffer can grow. This is a hard limit, and anything written to the buffer over this limit will result in an error. Default: 10,485,760

out_buffer_capacity: usize

The initial size of the outgoing buffer. A larger buffer uses more memory but will allow for fewer reallocations. Default: 2048

max_out_buffer_capacity: usize

The maximum size to which the outgoing buffer can grow. This is a hard limit, and anything written to the buffer over this limit will result in an error. Default: 10,485,760

panic_on_internal: bool

Whether to panic when an Internal error is encountered. Internal errors should generally not occur, so this setting defaults to true as a debug measure, whereas production applications should consider setting it to false. Default: true

panic_on_capacity: bool

Whether to panic when a Capacity error is encountered. Default: false

panic_on_protocol: bool

Whether to panic when a Protocol error is encountered. Default: false

panic_on_encoding: bool

Whether to panic when an Encoding error is encountered. Default: false

panic_on_queue: bool

Whether to panic when a Queue error is encountered. Default: false

panic_on_io: bool

Whether to panic when an Io error is encountered. Default: false

panic_on_timeout: bool

Whether to panic when a Timer error is encountered. Default: false

shutdown_on_interrupt: bool

Whether to shutdown the eventloop when an interrupt is received. Default: true

masking_strict: bool

The WebSocket protocol requires frames sent from client endpoints to be masked as a security and sanity precaution. Enforcing this requirement, which may be removed at some point may cause incompatibilities. If you need the extra security, set this to true. Default: false

key_strict: bool

The WebSocket protocol requires clients to verify the key returned by a server to ensure that the server and all intermediaries can perform the protocol. Verifying the key will consume processing time and other resources with the benefit that we can fail the connection early. The default in WS-RS is to accept any key from the server and instead fail late if a protocol error occurs. Change this setting to enable key verification. Default: false

method_strict: bool

The WebSocket protocol requires clients to perform an opening handshake using the HTTP GET method for the request. However, since only WebSockets are supported on the connection, verifying the method of handshake requests is not always necessary. To enforce the requirement that handshakes begin with a GET method, set this to true. Default: false

encrypt_server: bool

Indicate whether server connections should use ssl encryption when accepting connections. Setting this to true means that clients should use the wss scheme to connect to this server. Note that using this flag will in general necessitate overriding the Handler::upgrade_ssl_server method in order to provide the details of the ssl context. It may be simpler for most users to use a reverse proxy such as nginx to provide server side encryption.

Default: false

tcp_nodelay: bool

Disables Nagle’s algorithm. Usually tcp socket tries to accumulate packets to send them all together (every 200ms). When enabled socket will try to send packet as fast as possible.

Default: false

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.