Skip to main content

QueryResult

Struct QueryResult 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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: u64

The 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: State

Opaque query state token for subsequent /queryChanges calls.

§can_calculate_changes: bool

Whether the backend supports /queryChanges for this query.

Implementations§

Source§

impl QueryResult

Source

pub fn new( ids: Vec<Id>, position: u64, total: Option<u64>, query_state: State, can_calculate_changes: bool, ) -> Self

Construct a QueryResult.

Source

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.

Trait Implementations§

Source§

impl Debug for QueryResult

Source§

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

Formats the value using the given formatter. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.