pub struct HistoryOptions {
pub start_index: Option<u16>,
pub end_index: Option<u16>,
pub read_delay: Duration,
pub progress_callback: Option<ProgressCallback>,
pub use_adaptive_delay: bool,
pub checkpoint_callback: Option<CheckpointCallback>,
pub checkpoint_interval: usize,
}Expand description
Options for downloading history.
§Index Convention
Indices are 1-based to match the Aranet device protocol:
start_index: Some(1)means the first (oldest) readingend_index: Some(100)means the 100th readingstart_index: Nonedefaults to 1 (beginning)end_index: Nonedefaults to total_readings (end)
§Progress Reporting
Use with_progress to receive updates during download:
let options = HistoryOptions::default()
.with_progress(|p| println!("Progress: {:.1}%", p.overall_progress * 100.0));§Adaptive Read Delay
Use adaptive_delay to automatically adjust delay based on signal quality:
let options = HistoryOptions::default().adaptive_delay(true);§Resume Support
For long downloads, use checkpointing to allow resume on failure:
let checkpoint = HistoryCheckpoint::load("device_123")?;
let options = HistoryOptions::default().resume_from(checkpoint);Fields§
§start_index: Option<u16>Starting index (1-based, inclusive). If None, downloads from the beginning (index 1).
end_index: Option<u16>Ending index (1-based, inclusive). If None, downloads to the end (index = total_readings).
read_delay: DurationDelay between read operations to avoid overwhelming the device.
progress_callback: Option<ProgressCallback>Progress callback (optional).
use_adaptive_delay: boolWhether to use adaptive delay based on signal quality.
checkpoint_callback: Option<CheckpointCallback>Checkpoint callback for saving progress during download (optional). Called periodically with the current checkpoint state.
checkpoint_interval: usizeHow often to call the checkpoint callback (in records).
Implementations§
Source§impl HistoryOptions
impl HistoryOptions
Sourcepub fn start_index(self, index: u16) -> Self
pub fn start_index(self, index: u16) -> Self
Set the starting index (1-based).
Sourcepub fn read_delay(self, delay: Duration) -> Self
pub fn read_delay(self, delay: Duration) -> Self
Set the delay between read operations.
Sourcepub fn with_progress<F>(self, callback: F) -> Self
pub fn with_progress<F>(self, callback: F) -> Self
Set a progress callback.
Sourcepub fn report_progress(&self, progress: &HistoryProgress)
pub fn report_progress(&self, progress: &HistoryProgress)
Report progress if a callback is set.
Sourcepub fn adaptive_delay(self, enable: bool) -> Self
pub fn adaptive_delay(self, enable: bool) -> Self
Enable or disable adaptive delay based on signal quality.
When enabled, the read delay will be automatically adjusted based on the connection’s signal strength:
- Excellent signal: 30ms delay
- Good signal: 50ms delay
- Fair signal: 100ms delay
- Poor signal: 200ms delay
Sourcepub fn with_checkpoint<F>(self, callback: F) -> Self
pub fn with_checkpoint<F>(self, callback: F) -> Self
Set a checkpoint callback for saving download progress.
The callback will be invoked periodically (based on checkpoint_interval)
with the current checkpoint state, allowing recovery from interruptions.
Sourcepub fn checkpoint_interval(self, interval: usize) -> Self
pub fn checkpoint_interval(self, interval: usize) -> Self
Set how often to call the checkpoint callback (in records).
Default: 100 records
Sourcepub fn resume_from(self, checkpoint: &HistoryCheckpoint) -> Self
pub fn resume_from(self, checkpoint: &HistoryCheckpoint) -> Self
Resume from a previous checkpoint.
This sets the start_index based on the checkpoint’s resume position.
Sourcepub fn report_checkpoint(&self, checkpoint: &HistoryCheckpoint)
pub fn report_checkpoint(&self, checkpoint: &HistoryCheckpoint)
Report a checkpoint if a callback is set.
Sourcepub fn effective_read_delay(
&self,
signal_quality: Option<SignalQuality>,
) -> Duration
pub fn effective_read_delay( &self, signal_quality: Option<SignalQuality>, ) -> Duration
Get the effective read delay, optionally adjusted for signal quality.
Trait Implementations§
Source§impl Clone for HistoryOptions
impl Clone for HistoryOptions
Source§fn clone(&self) -> HistoryOptions
fn clone(&self) -> HistoryOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more