pub struct ReadingQuery {
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 current readings.
Use this to construct queries for Store::query_readings.
All filter methods are optional and can be chained in any order.
By default, queries return results ordered by captured_at descending
(newest first).
§Example
use aranet_store::ReadingQuery;
use time::{OffsetDateTime, Duration};
let now = OffsetDateTime::now_utc();
// Query last hour's readings for a device
let query = ReadingQuery::new()
.device("Aranet4 17C3C")
.since(now - Duration::hours(1))
.limit(100);
// Query with pagination
let page_2 = ReadingQuery::new()
.device("Aranet4 17C3C")
.limit(50)
.offset(50);
// Query oldest first (chronological order)
let chronological = ReadingQuery::new()
.device("Aranet4 17C3C")
.oldest_first();Fields§
§device_id: Option<String>Filter by device ID.
since: Option<OffsetDateTime>Filter readings after this time.
until: Option<OffsetDateTime>Filter readings before this time.
limit: Option<u32>Maximum number of results.
offset: Option<u32>Offset for pagination.
newest_first: boolOrder by captured_at descending (newest first).
Implementations§
Source§impl ReadingQuery
impl ReadingQuery
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 readings from the specified device.
Sourcepub fn since(self, time: OffsetDateTime) -> Self
pub fn since(self, time: OffsetDateTime) -> Self
Filter to readings captured at or after this time.
Useful for querying “last N hours” or “since last sync”.
Sourcepub fn until(self, time: OffsetDateTime) -> Self
pub fn until(self, time: OffsetDateTime) -> Self
Filter to readings captured 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 2
with 50 items per page: .limit(50).offset(50).
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 captured_at).
By default, queries return newest first. Use this for chronological ordering, useful when exporting or processing data sequentially.
Trait Implementations§
Source§impl Clone for ReadingQuery
impl Clone for ReadingQuery
Source§fn clone(&self) -> ReadingQuery
fn clone(&self) -> ReadingQuery
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more