pub struct ConstConfig {
    pub msg_size_hint: u32,
    pub sender_buffer: u32,
    pub receiver_buffer: u32,
    pub graceful_close_timeout_millis: u16,
    pub retrying_strategy: RetryingStrategies,
    pub socket_options: SocketOptions,
    pub channel: Channels,
    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 ifs, 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

§graceful_close_timeout_millis: u16

How many milliseconds to wait before giving up waiting for a socket to close.
Set this taking SocketOptions::linger_millis into account

§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

§channel: Channels

Allows changing the backing queue for the sender/receiver buffers

§executor_instruments: Instruments

Allows changing the Stream executor options in regard to logging & collected/reported metrics

Implementations§

source§

impl ConstConfig

source

pub const fn default() -> ConstConfig

Contains sane & performant defaults.
Usage example:

 const CONFIG: ConstConfig = ConstConfig {
    receiver_buffer: 1024,
    ..ConstConfig::default()
};
source

pub const fn into(self) -> u64

For use when instantiating a generic struct that uses the “Const Config Pattern” – when chosing a pre-defined configuration.
See also [Self::custom()].
Example:

    see bellow
source

pub const fn from(config: u64) -> Self

Builds Self from the generic const CONFIGS: usize parameter used in structs by the “Const Config Pattern”

source

pub const fn extract_receiver_buffer(config: u64) -> u32

source

pub const fn extract_executor_instruments(config: u64) -> usize

source

pub const fn extract_msg_size_hint(config: u64) -> u32

source

pub const fn extract_graceful_close_timeout(config: u64) -> Duration

source

pub const fn extract_retrying_strategy(config: u64) -> RetryingStrategies

source

pub const fn extract_socket_options(config: u64) -> SocketOptions

Trait Implementations§

source§

impl Debug for ConstConfig

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for ConstConfig

source§

fn eq(&self, other: &ConstConfig) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for ConstConfig

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V