#[non_exhaustive]pub struct QueryResult {
pub ids: Vec<Id>,
pub position: u64,
pub total: Option<u64>,
pub query_state: State,
pub can_calculate_changes: bool,
}Expand description
Result of a /query call (RFC 8620 §5.5).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.ids: Vec<Id>The ordered list of matching object ids.
position: u64The 0-based index of the first returned id in the complete result list.
RFC 8620 §5.5 specifies this as UnsignedInt in the response —
a non-negative integer (bd:JMAP-wlip.25). The request-side
position parameter accepts negative values as end-relative
offsets, but the response position cannot validly be negative.
Backends that derive position from a request-side i64
offset MUST clamp / normalize to u64 before constructing this
struct.
total: Option<u64>Total number of results, if the backend can calculate it.
query_state: StateOpaque query state token for subsequent /queryChanges calls.
can_calculate_changes: boolWhether the backend supports /queryChanges for this query.
Implementations§
Source§impl QueryResult
impl QueryResult
Sourcepub fn new(
ids: Vec<Id>,
position: u64,
total: Option<u64>,
query_state: State,
can_calculate_changes: bool,
) -> Self
pub fn new( ids: Vec<Id>, position: u64, total: Option<u64>, query_state: State, can_calculate_changes: bool, ) -> Self
Construct a QueryResult.
Sourcepub fn new_clamped(
ids: Vec<Id>,
position_signed: i64,
total: Option<u64>,
query_state: State,
can_calculate_changes: bool,
) -> Self
pub fn new_clamped( ids: Vec<Id>, position_signed: i64, total: Option<u64>, query_state: State, can_calculate_changes: bool, ) -> Self
Construct a QueryResult from a signed request-side position,
clamping negatives to 0 and normalizing to u64
(bd:JMAP-jfia.25).
RFC 8620 §5.5 specifies the response position as UnsignedInt,
but the request-side position parameter accepts negative
values as end-relative offsets. Backends typically receive the
signed value, walk the offset into the result list, and need
to surface the resulting 0-based index. This constructor takes
the resolved-offset value and clamps to u64, matching the
spec contract.
Negative inputs clamp to 0 (representing “the start of the
result list”). Backends that have already done the
offset-to-index resolution and have a u64 already SHOULD use
the plain Self::new constructor instead.