pub struct PageQuery {
pub date_from: Option<DateTime>,
pub date_to: Option<DateTime>,
pub offset: Option<u64>,
pub limit: Option<u64>,
}transport only.Expand description
The query parameters of a paginated GET.
date_from: Only return objects that havelast_updatedafter or equal to this Date/Time (inclusive).date_to: … up to this Date/Time, but not including (exclusive).
The half-open interval is the point: “when sequential requests to the same end-point are
done, the next interval will have no overlap and the date_from of the next interval is
simply the date_to of the previous interval.” PageQuery::next_interval does that.
Spec: 2.3.0 §transport_and_format_paginated_request
Fields§
§date_from: Option<DateTime>Only objects with last_updated at or after this time. Inclusive.
date_to: Option<DateTime>Only objects with last_updated before this time. Exclusive.
offset: Option<u64>The offset of the first object returned. Absent means 0.
limit: Option<u64>The maximum number of objects to return. The server may return fewer.
Implementations§
Source§impl PageQuery
impl PageQuery
Sourcepub fn new() -> Self
pub fn new() -> Self
An empty query: everything, from the beginning, at the server’s own page size.
Sourcepub fn with_limit(self, limit: u64) -> Self
pub fn with_limit(self, limit: u64) -> Self
This query with an explicit page size.
Sourcepub fn with_offset(self, offset: u64) -> Self
pub fn with_offset(self, offset: u64) -> Self
This query with an explicit offset.
Sourcepub fn offset_or_default(&self) -> u64
pub fn offset_or_default(&self) -> u64
The offset, applying the spec’s default of 0.
Sourcepub fn next_interval(&self, new_end: DateTime) -> Option<Self>
pub fn next_interval(&self, new_end: DateTime) -> Option<Self>
The query for the next time interval, starting where this one ended.
Returns None when this query has no date_to to continue from.
Sourcepub fn to_query_string(&self) -> String
pub fn to_query_string(&self) -> String
The query string, with the parameters in the order the spec’s examples use.
Returns an empty string when nothing is set, so it can be appended unconditionally.
Sourcepub fn clamped_to(self, max: u64) -> Self
pub fn clamped_to(self, max: u64) -> Self
Clamps limit to max, as a peer’s advertised X-Limit requires.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PageQuery
impl<'de> Deserialize<'de> for PageQuery
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for PageQuery
Source§impl JsonSchema for PageQuery
impl JsonSchema for PageQuery
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreimpl StructuralPartialEq for PageQuery
Auto Trait Implementations§
impl Freeze for PageQuery
impl RefUnwindSafe for PageQuery
impl Send for PageQuery
impl Sync for PageQuery
impl Unpin for PageQuery
impl UnsafeUnpin for PageQuery
impl UnwindSafe for PageQuery
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.