Struct ReconnectOptions
#[non_exhaustive]pub struct ReconnectOptions {
pub initial_delay: Duration,
pub max_delay: Duration,
pub multiplier: BackoffMultiplier,
pub jitter: Jitter,
pub stop_on_fatal_rejection: bool,
}Expand description
Configuration for automatic reconnection with exponential backoff.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.initial_delay: DurationInitial delay before the first reconnection attempt.
max_delay: DurationMaximum delay between reconnection attempts.
multiplier: BackoffMultiplierMultiplicative factor applied after each failed attempt.
jitter: JitterRandom jitter fraction applied to each delay.
stop_on_fatal_rejection: boolWhether a CONNACK rejection that needs operator intervention
(unsupported protocol version, invalid client id, bad credentials,
not authorized, banned) stops the reconnect loop with a final
Rejected status. Defaults
to false because such rejections are often fixed server-side. The
client then keeps retrying with backoff.
Implementations§
Source§impl ReconnectOptions
impl ReconnectOptions
Sourcepub const fn new() -> ReconnectOptions
pub const fn new() -> ReconnectOptions
Creates options with sensible defaults. The delay starts at 1 s, grows by a factor of 2 up to 30 s and has 25% jitter. The client retries on every rejection.
Sourcepub const fn initial_delay(self, delay: Duration) -> ReconnectOptions
pub const fn initial_delay(self, delay: Duration) -> ReconnectOptions
Sets the initial delay before the first reconnection attempt.
Sourcepub const fn max_delay(self, delay: Duration) -> ReconnectOptions
pub const fn max_delay(self, delay: Duration) -> ReconnectOptions
Sets the maximum delay between reconnection attempts.
Sourcepub const fn multiplier(self, multiplier: BackoffMultiplier) -> ReconnectOptions
pub const fn multiplier(self, multiplier: BackoffMultiplier) -> ReconnectOptions
Sets the multiplicative factor applied after each failed attempt.
Sourcepub const fn jitter(self, jitter: Jitter) -> ReconnectOptions
pub const fn jitter(self, jitter: Jitter) -> ReconnectOptions
Sets the random jitter fraction applied to each delay.
Sourcepub const fn stop_on_fatal_rejection(self, stop: bool) -> ReconnectOptions
pub const fn stop_on_fatal_rejection(self, stop: bool) -> ReconnectOptions
Sets whether a fatal CONNACK rejection stops the reconnect loop (see
stop_on_fatal_rejection).
Trait Implementations§
Source§impl Debug for ReconnectOptions
impl Debug for ReconnectOptions
Source§impl Default for ReconnectOptions
impl Default for ReconnectOptions
Source§fn default() -> ReconnectOptions
fn default() -> ReconnectOptions
Auto Trait Implementations§
impl Freeze for ReconnectOptions
impl RefUnwindSafe for ReconnectOptions
impl Send for ReconnectOptions
impl Sync for ReconnectOptions
impl Unpin for ReconnectOptions
impl UnsafeUnpin for ReconnectOptions
impl UnwindSafe for ReconnectOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more