pub struct ConstConfig {
pub msg_size_hint: u32,
pub sender_buffer: u32,
pub receiver_buffer: u32,
pub flush_timeout_millis: u16,
pub retrying_strategy: RetryingStrategies,
pub socket_options: SocketOptions,
pub executor_instruments: Instruments,
}
Expand description
Implements something that could be called the “Zero-Cost Const Configuration Pattern”, that produces a usize
whose goal is to be the only const parameter of a generic struct (avoiding the alternative of bloating it with several const params).
When using the const “query functions” defined here in if
s, the compiler will have the opportunity to cancel out any unreachable code (zero-cost abstraction).
Some commonly used combinations may be pre-defined in some enum variants, but you may always build unmapped possibilities through [Self::custom()].
Usage examples:
see bellow
Fields§
§msg_size_hint: u32
Pre-allocates the sender/receiver buffers to this value (power of 2).
Setting it wisely may economize some realloc
calls
sender_buffer: u32
How many messages (per peer) may be enqueued for output (power of 2) before operations start to fail
receiver_buffer: u32
How many messages (per peer) may be enqueued for processing (power of 2) before operations start to fail
flush_timeout_millis: u16
How many milliseconds to wait when flushing messages out to a to-be-closed connection.
retrying_strategy: RetryingStrategies
Specifies what to do when operations fail (full buffers / connection droppings)
socket_options: SocketOptions
Messes with the low level (system) socket options
executor_instruments: Instruments
Allows changing the Stream executor options in regard to logging & collected/reported metrics
Implementations§
Source§impl ConstConfig
impl ConstConfig
Sourcepub const fn default() -> ConstConfig
pub const fn default() -> ConstConfig
Contains sane & performant defaults.
Usage example:
const CONFIG: ConstConfig = ConstConfig {
receiver_buffer: 1024,
..ConstConfig::default()
};
Sourcepub const fn into(self) -> u64
pub const fn into(self) -> u64
For use when instantiating a generic struct that uses the “Const Config Pattern”
– when choosing a pre-defined configuration.
See also [Self::custom()].
Example:
see bellow
Sourcepub const fn from(config: u64) -> Self
pub const fn from(config: u64) -> Self
Builds Self from the generic const CONFIGS: usize
parameter used in structs
by the “Const Config Pattern”