From e8a8b5976bd5ab7daa2608e4a10be9079b17909e Mon Sep 17 00:00:00 2001 From: TotallyNot <44345987+TotallyNot@users.noreply.github.com> Date: Tue, 2 Apr 2024 21:06:41 +0200 Subject: [PATCH] expose request in builder --- torn-api/Cargo.toml | 2 +- torn-api/benches/deserialisation_benchmark.rs | 6 +++--- torn-api/src/de_util.rs | 4 +--- torn-api/src/lib.rs | 4 ++-- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/torn-api/Cargo.toml b/torn-api/Cargo.toml index 187b0db..822ed35 100644 --- a/torn-api/Cargo.toml +++ b/torn-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "torn-api" -version = "0.6.6" +version = "0.6.7" edition = "2021" rust-version = "1.75.0" authors = ["Pyrit [2111649]"] diff --git a/torn-api/benches/deserialisation_benchmark.rs b/torn-api/benches/deserialisation_benchmark.rs index 945eb5f..0eb52b0 100644 --- a/torn-api/benches/deserialisation_benchmark.rs +++ b/torn-api/benches/deserialisation_benchmark.rs @@ -15,7 +15,7 @@ pub fn user_benchmark(c: &mut Criterion) { client .torn_api(key) .user(|b| { - b.selections(&[ + b.selections([ user::Selection::Basic, user::Selection::Discord, user::Selection::Profile, @@ -49,7 +49,7 @@ pub fn faction_benchmark(c: &mut Criterion) { client .torn_api(key) - .faction(|b| b.selections(&[faction::Selection::Basic])) + .faction(|b| b.selections([faction::Selection::Basic])) .await .unwrap() }); @@ -74,7 +74,7 @@ pub fn attacks_full(c: &mut Criterion) { client .torn_api(key) - .faction(|b| b.selections(&[faction::Selection::AttacksFull])) + .faction(|b| b.selections([faction::Selection::AttacksFull])) .await .unwrap() }); diff --git a/torn-api/src/de_util.rs b/torn-api/src/de_util.rs index 073ffc5..939cfa6 100644 --- a/torn-api/src/de_util.rs +++ b/torn-api/src/de_util.rs @@ -39,9 +39,7 @@ where if i == 0 { Ok(None) } else { - let naive = NaiveDateTime::from_timestamp_opt(i, 0) - .ok_or_else(|| D::Error::invalid_value(Unexpected::Signed(i), &"Epoch timestamp"))?; - Ok(Some(DateTime::from_utc(naive, Utc))) + Ok(DateTime::from_timestamp(i, 0)) } } diff --git a/torn-api/src/lib.rs b/torn-api/src/lib.rs index cec01e7..3690feb 100644 --- a/torn-api/src/lib.rs +++ b/torn-api/src/lib.rs @@ -223,8 +223,8 @@ pub struct ApiRequestBuilder where A: ApiSelection, { - request: ApiRequest, - id: Option, + pub request: ApiRequest, + pub id: Option, } impl Default for ApiRequestBuilder