add support for new before/after_id filters

This commit is contained in:
Robin Appelman 2022-06-28 20:15:33 +02:00
commit 6beeed435c
2 changed files with 22 additions and 2 deletions

View file

@ -324,6 +324,8 @@ pub struct ListParams {
after: Option<OffsetDateTime>,
#[serde(serialize_with = "serialize_option_time")]
before: Option<OffsetDateTime>,
before_id: Option<u64>,
after_id: Option<u64>,
}
fn serialize_option_time<S>(dt: &Option<OffsetDateTime>, serializer: S) -> Result<S::Ok, S::Error>
@ -441,6 +443,24 @@ impl ListParams {
}
}
/// Specify the maximum demo id to filter demos with
#[must_use]
pub fn with_before_id(self, before: u64) -> Self {
ListParams {
before_id: Some(before),
..self
}
}
/// Specify the minimum demo id to filter demos with
#[must_use]
pub fn with_after_id(self, after: u64) -> Self {
ListParams {
after_id: Some(after),
..self
}
}
/// Specify the sort
#[must_use]
pub fn with_order(self, order: ListOrder) -> Self {