Struct stream_reconnect::ReconnectOptions[][src]

pub struct ReconnectOptions(_);
Expand description

User specified options that control the behavior of the ReconnectStream upon disconnect.

Implementations

By default, the ReconnectStream will not try to reconnect if the first connect attempt fails. By default, the retries iterator waits longer and longer between reconnection attempts, until it eventually perpetually tries to reconnect every 30 minutes.

Represents a function that generates an Iterator to schedule the wait between reconnection attempts. This method allows the user to provide any function that returns a value which is convertible into an iterator, such as an actual iterator or a Vec.

Examples
use std::time::Duration;
use stream_reconnect::ReconnectOptions;

// With the below vector, the ReconnectStream item will try to reconnect three times,
// waiting 2 seconds between each attempt. Once all three tries are exhausted,
// it will stop attempting.
let options = ReconnectOptions::new().with_retries_generator(|| {
    vec![
        Duration::from_secs(2),
        Duration::from_secs(2),
        Duration::from_secs(2),
    ]
});

If this is set to true, if the initial connect method of the ReconnectStream item fails, then no further reconnects will be attempted

Invoked when the ReconnectStream establishes a connection

Invoked when the ReconnectStream loses its active connection

Invoked when the ReconnectStream fails a connection attempt

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. 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

Performs the conversion.

Performs the conversion.

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)

recently added

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.