From eab748bf990a304063c476fb7cdeab0ec8c325f7 Mon Sep 17 00:00:00 2001 From: Jake Swenson Date: Mon, 30 Aug 2021 08:27:10 -0700 Subject: Improve ergonomics --- src/models/search.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/models/search.rs') diff --git a/src/models/search.rs b/src/models/search.rs index 3e5d782..22dab76 100644 --- a/src/models/search.rs +++ b/src/models/search.rs @@ -1,5 +1,5 @@ use crate::ids::{PageId, UserId}; -use crate::models::paging::Paging; +use crate::models::paging::{Pageable, Paging}; use crate::models::Number; use chrono::{DateTime, Utc}; use serde::ser::SerializeMap; @@ -290,7 +290,7 @@ pub struct DatabaseSort { pub direction: SortDirection, } -#[derive(Serialize, Debug, Eq, PartialEq, Default)] +#[derive(Serialize, Debug, Eq, PartialEq, Default, Clone)] pub struct DatabaseQuery { #[serde(skip_serializing_if = "Option::is_none")] pub sorts: Option>, @@ -300,6 +300,15 @@ pub struct DatabaseQuery { pub paging: Option, } +impl Pageable for DatabaseQuery { + fn start_from(self, starting_point: Paging) -> Self { + DatabaseQuery { + paging: Some(starting_point), + ..self + } + } +} + #[derive(Debug, Eq, PartialEq)] pub enum NotionSearch { /// When supplied, limits which pages are returned by comparing the query to the page title. -- cgit v1.2.3