mirror of
https://codeberg.org/demostf/api-client.git
synced 2026-06-03 08:34:15 +02:00
add support for new before/after_id filters
This commit is contained in:
parent
46f548fcb4
commit
6beeed435c
2 changed files with 22 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "demostf-client"
|
name = "demostf-client"
|
||||||
version = "0.4.1"
|
version = "0.4.2"
|
||||||
authors = ["Robin Appelman <robin@icewind.nl>"]
|
authors = ["Robin Appelman <robin@icewind.nl>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Api client for demos.tf"
|
description = "Api client for demos.tf"
|
||||||
|
|
@ -26,7 +26,7 @@ md5 = "0.7.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { version = "1", features = ["macros"] }
|
tokio = { version = "1", features = ["macros"] }
|
||||||
sqlx = { version = "0.5", features = ["postgres", "runtime-tokio-rustls"] }
|
sqlx = { version = "0.6", features = ["postgres", "runtime-tokio-rustls"] }
|
||||||
tracing-subscriber = { version = "0.3.11", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.11", features = ["env-filter"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
|
||||||
20
src/lib.rs
20
src/lib.rs
|
|
@ -324,6 +324,8 @@ pub struct ListParams {
|
||||||
after: Option<OffsetDateTime>,
|
after: Option<OffsetDateTime>,
|
||||||
#[serde(serialize_with = "serialize_option_time")]
|
#[serde(serialize_with = "serialize_option_time")]
|
||||||
before: Option<OffsetDateTime>,
|
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>
|
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
|
/// Specify the sort
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_order(self, order: ListOrder) -> Self {
|
pub fn with_order(self, order: ListOrder) -> Self {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue