Skip to main content

QueryParams

Struct QueryParams 

Source
#[non_exhaustive]
pub struct QueryParams<'a, O: QueryObject> { pub filter: Option<&'a O::Filter>, pub sort: Option<&'a [O::Comparator]>, pub limit: Option<u64>, pub position: i64, pub anchor: Option<&'a Id>, pub anchor_offset: i64, pub language: Option<&'a [LanguageRange]>, }
Expand description

The /query arguments (RFC 8620 §5.5) passed to JmapReads::query_objects, after accountId.

#[non_exhaustive] so a new RFC or extension argument is a new field, not a breaking change to every backend (bd:JMAP-wf92.7). Backends read the public fields; callers build one with QueryParams::new and the setters:

let filter = serde_json::json!({"text": "hello"});
let params = QueryParams::<Foo>::new().filter(Some(&filter)).limit(Some(50));
assert_eq!(params.position, 0);

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.
§filter: Option<&'a O::Filter>

filter; None matches every object.

§sort: Option<&'a [O::Comparator]>

sort; None leaves the order to the server.

§limit: Option<u64>

limit; None means no client limit.

§position: i64

position. Negative values count from the end of the results (RFC 8620 §5.5); ignored when anchor is set.

§anchor: Option<&'a Id>

anchor: start the page at this id’s index instead of position.

§anchor_offset: i64

anchorOffset, added to the anchor’s index; ignored without an anchor.

§language: Option<&'a [LanguageRange]>

language (draft-atwood-jmap-updates-00 §4.2.2): sort and filter on a localizable property (JmapObject::LOCALIZABLE) compare the value /get with these ranges returns (jmap_types::i18n::localized_value), not the base value. None compares stored values. Set only for an account whose JmapAccounts::i18n_info is Some; such a backend MUST honour it.

Implementations§

Source§

impl<'a, O: QueryObject> QueryParams<'a, O>

Source

pub fn new() -> Self

The RFC 8620 §5.5 defaults: no filter, sort, limit or anchor, and position and anchorOffset 0.

Source

pub fn filter(self, filter: Option<&'a O::Filter>) -> Self

Set filter.

Source

pub fn sort(self, sort: Option<&'a [O::Comparator]>) -> Self

Set sort.

Source

pub fn limit(self, limit: Option<u64>) -> Self

Set limit.

Source

pub fn position(self, position: i64) -> Self

Set position.

Source

pub fn anchor(self, anchor: Option<&'a Id>) -> Self

Set anchor.

Source

pub fn anchor_offset(self, anchor_offset: i64) -> Self

Source

pub fn language(self, language: Option<&'a [LanguageRange]>) -> Self

Set language.

Trait Implementations§

Source§

impl<O: QueryObject> Clone for QueryParams<'_, O>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<O: QueryObject> Copy for QueryParams<'_, O>

Source§

impl<O: QueryObject> Debug for QueryParams<'_, O>
where O::Filter: Debug, O::Comparator: Debug,

Source§

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

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

impl<O: QueryObject> Default for QueryParams<'_, O>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a, O> Forget for QueryParams<'a, O>

§

impl<'a, O> Freeze for QueryParams<'a, O>
where Option<&'a <O as QueryObject>::Filter>: Freeze, Option<&'a [<O as QueryObject>::Comparator]>: Freeze,

§

impl<'a, O> Move for QueryParams<'a, O>

§

impl<'a, O> RefUnwindSafe for QueryParams<'a, O>

§

impl<'a, O> Send for QueryParams<'a, O>
where Option<&'a <O as QueryObject>::Filter>: Send, Option<&'a [<O as QueryObject>::Comparator]>: Send,

§

impl<'a, O> Sync for QueryParams<'a, O>
where Option<&'a <O as QueryObject>::Filter>: Sync, Option<&'a [<O as QueryObject>::Comparator]>: Sync,

§

impl<'a, O> Unpin for QueryParams<'a, O>
where Option<&'a <O as QueryObject>::Filter>: Unpin, Option<&'a [<O as QueryObject>::Comparator]>: Unpin,

§

impl<'a, O> UnsafeUnpin for QueryParams<'a, O>

§

impl<'a, O> UnwindSafe for QueryParams<'a, O>

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> ErasedDestructor for T
where T: 'static,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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