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: boolIf true, order by timestamp descending (newest first). Default: true.
Implementations§
Source§impl HistoryQuery
impl HistoryQuery
Sourcepub fn new() -> Self
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
Sourcepub fn device(self, device_id: &str) -> Self
pub fn device(self, device_id: &str) -> Self
Filter by device ID.
Only include history records from the specified device.
Sourcepub fn since(self, time: OffsetDateTime) -> Self
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.
Sourcepub fn until(self, time: OffsetDateTime) -> Self
pub fn until(self, time: OffsetDateTime) -> Self
Filter to records at or before this time.
Use with since() to query a specific time range.
Sourcepub fn limit(self, limit: u32) -> Self
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.
Sourcepub fn offset(self, offset: u32) -> Self
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.
Sourcepub fn oldest_first(self) -> Self
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
impl Clone for HistoryQuery
Source§fn clone(&self) -> HistoryQuery
fn clone(&self) -> HistoryQuery
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more