Skip to content

Commit 1431a45

Browse files
committed
make async-trait optional
1 parent c1c1ee3 commit 1431a45

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ readme = "README.md"
1212
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1313
[features]
1414
default = []
15-
client = []
15+
client = ["dep:async-trait"]
1616
reqwest = ["dep:reqwest", "client"]
1717
surf_client_curl = ["surf", "surf/curl-client"]
1818
surf = ["dep:surf", "dep:http-types", "http-types?/hyperium_http", "client"]
@@ -24,7 +24,7 @@ thiserror = "1.0.29"
2424
displaydoc = "0.2.3"
2525
serde = { version = "1.0.130", features = ["derive"] }
2626
serde_json = "1.0.68"
27-
async-trait = "0.1.51"
27+
async-trait = { version = "0.1.51", optional = true }
2828
http = "0.2.5"
2929
surf = { version = "2.3.1", optional = true, default-features = false }
3030
reqwest = { version = "0.11.4", optional = true, default-features = false }

src/tokens.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub enum BearerTokenType {
3232
}
3333

3434
/// Trait for twitch tokens to get fields and generalize over [AppAccessToken] and [UserToken]
35-
#[async_trait::async_trait]
35+
#[cfg_attr(feature = "client", async_trait::async_trait)]
3636
pub trait TwitchToken {
3737
/// Get the type of token.
3838
fn token_type() -> BearerTokenType;
@@ -120,7 +120,7 @@ pub trait TwitchToken {
120120
}
121121
}
122122

123-
#[async_trait::async_trait]
123+
#[cfg_attr(feature = "client", async_trait::async_trait)]
124124
impl<T: TwitchToken + Send> TwitchToken for Box<T> {
125125
fn token_type() -> BearerTokenType { T::token_type() }
126126

src/tokens/app_access_token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl std::fmt::Debug for AppAccessToken {
4646
}
4747
}
4848

49-
#[async_trait::async_trait]
49+
#[cfg_attr(feature = "client", async_trait::async_trait)]
5050
impl TwitchToken for AppAccessToken {
5151
fn token_type() -> super::BearerTokenType { super::BearerTokenType::AppAccessToken }
5252

src/tokens/user_token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl UserToken {
229229
pub fn set_secret(&mut self, secret: Option<ClientSecret>) { self.client_secret = secret }
230230
}
231231

232-
#[async_trait::async_trait]
232+
#[cfg_attr(feature = "client", async_trait::async_trait)]
233233
impl TwitchToken for UserToken {
234234
fn token_type() -> super::BearerTokenType { super::BearerTokenType::UserToken }
235235

0 commit comments

Comments
 (0)