From 9505ccc67e44023c5436597c72a545fd9d7c293e Mon Sep 17 00:00:00 2001 From: TotallyNot <44345987+TotallyNot@users.noreply.github.com> Date: Wed, 31 Aug 2022 23:51:25 +0200 Subject: [PATCH] actually implement new trait --- torn-key-pool/Cargo.toml | 15 +++++++++++---- torn-key-pool/src/lib.rs | 8 +++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/torn-key-pool/Cargo.toml b/torn-key-pool/Cargo.toml index a3b521c..506c1d9 100644 --- a/torn-key-pool/Cargo.toml +++ b/torn-key-pool/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "torn-key-pool" -version = "0.1.1" +version = "0.1.2" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -8,14 +8,20 @@ edition = "2021" [features] default = [ "postgres" ] postgres = [ "dep:sqlx", "dep:chrono", "dep:indoc" ] +reqwest = [ "dep:reqwest", "torn-api/reqwest" ] +awc = [ "dep:awc", "torn-api/awc" ] [dependencies] torn-api = { path = "../torn-api", default-features = false } +async-trait = "0.1" +thiserror = "1" + sqlx = { version = "0.6", features = [ "postgres", "chrono" ], optional = true } chrono = { version = "0.4", optional = true } indoc = { version = "1", optional = true } -async-trait = "0.1" -thiserror = "1" + +reqwest = { version = "0.11", default-features = false, features = [ "json" ], optional = true } +awc = { version = "3", default-features = false, optional = true } [dev-dependencies] torn-api = { path = "../torn-api", features = [ "reqwest" ] } @@ -23,4 +29,5 @@ sqlx = { version = "*", features = [ "runtime-tokio-rustls" ] } dotenv = "0.15.0" tokio = { version = "1.20.1", features = ["test-util", "rt", "macros"] } tokio-test = "0.4.2" -reqwest = { version = "0.11", features = [ "json" ] } +reqwest = { version = "*", default-features = true } +awc = { version = "*", features = [ "rustls" ] } diff --git a/torn-key-pool/src/lib.rs b/torn-key-pool/src/lib.rs index 912ac48..bad2341 100644 --- a/torn-key-pool/src/lib.rs +++ b/torn-key-pool/src/lib.rs @@ -128,7 +128,7 @@ where } } -pub trait ApiClientExt: ApiClient { +pub trait KeyPoolClient: ApiClient { fn with_pool<'a, S>(&'a self, domain: KeyDomain, storage: &'a S) -> KeyPoolExecutor where Self: Sized, @@ -137,3 +137,9 @@ pub trait ApiClientExt: ApiClient { KeyPoolExecutor::new(self, storage, domain) } } + +#[cfg(feature = "reqwest")] +impl KeyPoolClient for reqwest::Client {} + +#[cfg(feature = "awc")] +impl KeyPoolClient for awc::Client {}