expose request in builder

This commit is contained in:
TotallyNot 2024-04-02 21:06:41 +02:00
parent 7cfb715e0c
commit 01bbe37876
4 changed files with 7 additions and 9 deletions

View file

@ -1,6 +1,6 @@
[package] [package]
name = "torn-api" name = "torn-api"
version = "0.6.6" version = "0.6.7"
edition = "2021" edition = "2021"
rust-version = "1.75.0" rust-version = "1.75.0"
authors = ["Pyrit [2111649]"] authors = ["Pyrit [2111649]"]

View file

@ -15,7 +15,7 @@ pub fn user_benchmark(c: &mut Criterion) {
client client
.torn_api(key) .torn_api(key)
.user(|b| { .user(|b| {
b.selections(&[ b.selections([
user::Selection::Basic, user::Selection::Basic,
user::Selection::Discord, user::Selection::Discord,
user::Selection::Profile, user::Selection::Profile,
@ -49,7 +49,7 @@ pub fn faction_benchmark(c: &mut Criterion) {
client client
.torn_api(key) .torn_api(key)
.faction(|b| b.selections(&[faction::Selection::Basic])) .faction(|b| b.selections([faction::Selection::Basic]))
.await .await
.unwrap() .unwrap()
}); });
@ -74,7 +74,7 @@ pub fn attacks_full(c: &mut Criterion) {
client client
.torn_api(key) .torn_api(key)
.faction(|b| b.selections(&[faction::Selection::AttacksFull])) .faction(|b| b.selections([faction::Selection::AttacksFull]))
.await .await
.unwrap() .unwrap()
}); });

View file

@ -39,9 +39,7 @@ where
if i == 0 { if i == 0 {
Ok(None) Ok(None)
} else { } else {
let naive = NaiveDateTime::from_timestamp_opt(i, 0) Ok(DateTime::from_timestamp(i, 0))
.ok_or_else(|| D::Error::invalid_value(Unexpected::Signed(i), &"Epoch timestamp"))?;
Ok(Some(DateTime::from_utc(naive, Utc)))
} }
} }

View file

@ -223,8 +223,8 @@ pub struct ApiRequestBuilder<A>
where where
A: ApiSelection, A: ApiSelection,
{ {
request: ApiRequest<A>, pub request: ApiRequest<A>,
id: Option<String>, pub id: Option<String>,
} }
impl<A> Default for ApiRequestBuilder<A> impl<A> Default for ApiRequestBuilder<A>