pub struct KeysetPaginationParams<K> {
pub after: Option<K>,
pub before: Option<K>,
pub limit: Option<u64>,
}Expand description
Query parameters for keyset (seek-based) pagination.
Keyset pagination is more efficient than offset pagination for large datasets because the database anchors the query on an indexed column value rather than skipping rows.
after— fetch items whose sort key is greater than this valuebefore— fetch items whose sort key is less than this valuelimit— maximum number of items to return (1–100, default 20)
Typically only one of after / before is supplied per request.
Requires std or alloc.
Fields§
§after: Option<K>Fetch items after (exclusive) this key value.
before: Option<K>Fetch items before (exclusive) this key value.
limit: Option<u64>Maximum number of items to return (1–100). Defaults to 20.
Implementations§
Source§impl<K> KeysetPaginationParams<K>
impl<K> KeysetPaginationParams<K>
Sourcepub fn new(
limit: u64,
after: Option<K>,
before: Option<K>,
) -> Result<Self, ValidationError>
pub fn new( limit: u64, after: Option<K>, before: Option<K>, ) -> Result<Self, ValidationError>
Create validated keyset pagination params.
Returns Err if limit is outside 1–100.
§Examples
use api_bones::pagination::KeysetPaginationParams;
let p = KeysetPaginationParams::<String>::new(10, None, None).unwrap();
assert_eq!(p.limit(), 10);
assert!(KeysetPaginationParams::<String>::new(0, None, None).is_err());
assert!(KeysetPaginationParams::<String>::new(101, None, None).is_err());Trait Implementations§
Source§impl<K: Clone> Clone for KeysetPaginationParams<K>
impl<K: Clone> Clone for KeysetPaginationParams<K>
Source§fn clone(&self) -> KeysetPaginationParams<K>
fn clone(&self) -> KeysetPaginationParams<K>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<K: Debug> Debug for KeysetPaginationParams<K>
impl<K: Debug> Debug for KeysetPaginationParams<K>
Source§impl<K> Default for KeysetPaginationParams<K>
Available on crate features std or alloc only.
impl<K> Default for KeysetPaginationParams<K>
Available on crate features
std or alloc only.Source§impl<'de, K> Deserialize<'de> for KeysetPaginationParams<K>where
K: Deserialize<'de> + Default,
impl<'de, K> Deserialize<'de> for KeysetPaginationParams<K>where
K: Deserialize<'de> + Default,
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<K: PartialEq> PartialEq for KeysetPaginationParams<K>
impl<K: PartialEq> PartialEq for KeysetPaginationParams<K>
Source§impl<K> Serialize for KeysetPaginationParams<K>where
K: Serialize,
impl<K> Serialize for KeysetPaginationParams<K>where
K: Serialize,
Source§impl<K> Validate for KeysetPaginationParams<K>
impl<K> Validate for KeysetPaginationParams<K>
Source§impl<'v_a, K> ValidateArgs<'v_a> for KeysetPaginationParams<K>
impl<'v_a, K> ValidateArgs<'v_a> for KeysetPaginationParams<K>
impl<K: Eq> Eq for KeysetPaginationParams<K>
impl<K> StructuralPartialEq for KeysetPaginationParams<K>
Auto Trait Implementations§
impl<K> Freeze for KeysetPaginationParams<K>where
K: Freeze,
impl<K> RefUnwindSafe for KeysetPaginationParams<K>where
K: RefUnwindSafe,
impl<K> Send for KeysetPaginationParams<K>where
K: Send,
impl<K> Sync for KeysetPaginationParams<K>where
K: Sync,
impl<K> Unpin for KeysetPaginationParams<K>where
K: Unpin,
impl<K> UnsafeUnpin for KeysetPaginationParams<K>where
K: UnsafeUnpin,
impl<K> UnwindSafe for KeysetPaginationParams<K>where
K: UnwindSafe,
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
Mutably borrows from an owned value. Read more