Skip to main content

HistoryQuery

Struct HistoryQuery 

Source
pub struct HistoryQuery {
    pub device_id: Option<String>,
    pub since: Option<OffsetDateTime>,
    pub until: Option<OffsetDateTime>,
    pub limit: Option<u32>,
    pub offset: Option<u32>,
    pub newest_first: bool,
}
Expand description

Fluent query builder for history records.

Use this to construct queries for Store::query_history, Store::history_stats, and export methods. All filter methods are optional and can be chained in any order.

By default, queries return results ordered by timestamp descending (newest first).

§Example

use aranet_store::HistoryQuery;
use time::{OffsetDateTime, Duration};

let now = OffsetDateTime::now_utc();

// Query last week's history
let query = HistoryQuery::new()
    .device("Aranet4 17C3C")
    .since(now - Duration::days(7));

// Query specific date range for export
let export_query = HistoryQuery::new()
    .device("Aranet4 17C3C")
    .since(now - Duration::days(30))
    .until(now - Duration::days(7))
    .oldest_first();

Fields§

§device_id: Option<String>

Filter by device ID (optional).

§since: Option<OffsetDateTime>

Include only records at or after this time (optional).

§until: Option<OffsetDateTime>

Include only records at or before this time (optional).

§limit: Option<u32>

Maximum number of results to return (optional).

§offset: Option<u32>

Number of results to skip for pagination (optional).

§newest_first: bool

If true, order by timestamp descending (newest first). Default: true.

Implementations§

Source§

impl HistoryQuery

Source

pub fn new() -> Self

Create a new query with default settings.

Default behavior:

  • No device filter (all devices)
  • No time range filter
  • No limit (all matching records)
  • Ordered by newest first
Source

pub fn device(self, device_id: &str) -> Self

Filter by device ID.

Only include history records from the specified device.

Source

pub fn since(self, time: OffsetDateTime) -> Self

Filter to records at or after this time.

Useful for querying “last N days” or data after a specific point.

Source

pub fn until(self, time: OffsetDateTime) -> Self

Filter to records at or before this time.

Use with since() to query a specific time range.

Source

pub fn limit(self, limit: u32) -> Self

Limit the maximum number of results returned.

Use with offset() for pagination. Values are capped at MAX_QUERY_LIMIT to prevent resource exhaustion.

Source

pub fn offset(self, offset: u32) -> Self

Skip the first N results.

Use with limit() for pagination. For example, to get page 3 with 100 items per page: .limit(100).offset(200).

Values are capped at MAX_QUERY_LIMIT to prevent degenerate queries.

Source

pub fn oldest_first(self) -> Self

Order results by oldest first (ascending by timestamp).

By default, queries return newest first. Use this for chronological ordering, which is useful for CSV export or time-series analysis.

Trait Implementations§

Source§

impl Clone for HistoryQuery

Source§

fn clone(&self) -> HistoryQuery

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 HistoryQuery

Source§

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

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

impl Default for HistoryQuery

Source§

fn default() -> HistoryQuery

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.

Source§

impl<T> Instrument for T

Source§

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

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

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.

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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