pub struct RetryConfig {
pub max_retries: u32,
pub initial_delay: Duration,
pub max_delay: Duration,
pub backoff_multiplier: f64,
pub jitter: bool,
}Expand description
Configuration for retry behavior.
Fields§
§max_retries: u32Maximum number of retry attempts (0 means no retries).
initial_delay: DurationInitial delay between retries.
max_delay: DurationMaximum delay between retries (for exponential backoff).
backoff_multiplier: f64Backoff multiplier (1.0 = constant delay, 2.0 = double each time).
jitter: boolWhether to add jitter to delays.
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn aggressive() -> Self
pub fn aggressive() -> Self
Conservative retry settings for unreliable connections.
Sourcepub fn for_scan() -> Self
pub fn for_scan() -> Self
Retry configuration optimized for device scanning.
Scanning often requires multiple attempts due to:
- BLE adapter warm-up
- Devices advertising at intervals (Aranet ~4s)
- RF interference
Uses aggressive, fast retries with short delays.
Sourcepub fn for_connect() -> Self
pub fn for_connect() -> Self
Retry configuration optimized for device connection.
Connections may fail due to:
- Device busy with another central
- Device in low-power mode (slower wake-up)
- Signal strength variations
Uses patient retries with longer delays to allow device recovery.
Sourcepub fn for_read() -> Self
pub fn for_read() -> Self
Retry configuration optimized for characteristic reads.
Reads may fail due to:
- Transient BLE errors
- Connection instability
- Device processing delay
Uses standard retries suitable for most read operations.
Sourcepub fn for_write() -> Self
pub fn for_write() -> Self
Retry configuration optimized for characteristic writes.
Writes may fail due to:
- BLE transmission errors
- Device busy processing previous write
- Connection instability
Uses careful retries with moderate delays.
Sourcepub fn for_history() -> Self
pub fn for_history() -> Self
Retry configuration optimized for history downloads.
History downloads are long-running operations that may fail due to:
- Connection drops during extended transfer
- Device timeout during large transfers
- BLE congestion from repeated reads
Uses persistent retries with longer delays, designed to work with checkpoint-based resumption for large downloads.
Sourcepub fn for_reconnect() -> Self
pub fn for_reconnect() -> Self
Retry configuration optimized for reconnection attempts.
After a connection loss, the device may need time to:
- Reset its BLE state
- Complete other operations
- Recover from low-power mode
Uses very patient retries with long delays.
Sourcepub fn quick() -> Self
pub fn quick() -> Self
Retry configuration for quick, time-sensitive operations.
For operations where speed is more important than reliability, uses minimal retries with very short delays.
Sourcepub fn max_retries(self, retries: u32) -> Self
pub fn max_retries(self, retries: u32) -> Self
Set maximum number of retries.
Sourcepub fn initial_delay(self, delay: Duration) -> Self
pub fn initial_delay(self, delay: Duration) -> Self
Set initial delay.
Sourcepub fn backoff_multiplier(self, multiplier: f64) -> Self
pub fn backoff_multiplier(self, multiplier: f64) -> Self
Set backoff multiplier.
Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
Source§fn clone(&self) -> RetryConfig
fn clone(&self) -> RetryConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more