Struct HistoryOptions

Source
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) reading
  • end_index: Some(100) means the 100th reading
  • start_index: None defaults to 1 (beginning)
  • end_index: None defaults 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: Duration

Delay between read operations to avoid overwhelming the device.

§progress_callback: Option<ProgressCallback>

Progress callback (optional).

§use_adaptive_delay: bool

Whether 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: usize

How often to call the checkpoint callback (in records).

Implementations§

Source§

impl HistoryOptions

Source

pub fn new() -> Self

Create new history options with default settings.

Source

pub fn start_index(self, index: u16) -> Self

Set the starting index (1-based).

Source

pub fn end_index(self, index: u16) -> Self

Set the ending index (1-based).

Source

pub fn read_delay(self, delay: Duration) -> Self

Set the delay between read operations.

Source

pub fn with_progress<F>(self, callback: F) -> Self
where F: Fn(HistoryProgress) + Send + Sync + 'static,

Set a progress callback.

Source

pub fn report_progress(&self, progress: &HistoryProgress)

Report progress if a callback is set.

Source

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
Source

pub fn with_checkpoint<F>(self, callback: F) -> Self
where F: Fn(HistoryCheckpoint) + Send + Sync + 'static,

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.

Source

pub fn checkpoint_interval(self, interval: usize) -> Self

Set how often to call the checkpoint callback (in records).

Default: 100 records

Source

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.

Source

pub fn report_checkpoint(&self, checkpoint: &HistoryCheckpoint)

Report a checkpoint if a callback is set.

Source

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

Source§

fn clone(&self) -> HistoryOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HistoryOptions

Source§

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

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

impl Default for HistoryOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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 T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more