twitch-rs / twitch_api

Rust library for talking with the Twitch API aka. "Helix", TMI and more! Use Twitch endpoints fearlessly!
Apache License 2.0
151 stars 33 forks source link

reqwest 0.12 upgraded hyper, http, and http-body to v1, causing build failures #401

Closed pajlada closed 7 months ago

pajlada commented 7 months ago

Reproducible with the eventsub example in this repo with the following patch:

diff --git a/examples/eventsub/Cargo.toml b/examples/eventsub/Cargo.toml
index 5ecd95bd2a..dc30eb9cd5 100644
--- a/examples/eventsub/Cargo.toml
+++ b/examples/eventsub/Cargo.toml
@@ -15,7 +15,7 @@ dotenvy = "0.15.7"
 eyre = { version = "0.6" }
 futures = "0.3.28"
 hyper = "0.14"
-reqwest = "0.11.22"
+reqwest = "0.12.0"
 retainer = "0.3.0"
 serde = "1.0.190"
 serde_derive = "1.0.190"

then running cargo build in the examples/eventsub directory

The error I see:

warning: the item `Cow` is imported redundantly
 --> src/eventsub/event.rs:5:5
  |
5 | use std::borrow::Cow;
  |     ^^^^^^^^^^^^^^^^
...
9 | use super::*;
  |     -------- the item `Cow` is already imported here
  |
  = note: `#[warn(unused_imports)]` on by default

warning: `twitch_api` (lib) generated 1 warning
   Compiling eventsub v0.1.0 (/home/pajlada/git/twitch_api/examples/eventsub)
error[E0599]: no function or associated item named `default_client_with_name` found for struct `reqwest::Client` in the current scope
    --> examples/eventsub/src/main.rs:61:28
     |
61   |         <reqwest::Client>::default_client_with_name(Some(
     |                            ^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `Client`
     |
note: if you're trying to build a new `reqwest::Client`, consider using `reqwest::Client::new` which returns `reqwest::Client`
    --> /home/pajlada/.cargo/registry/src/index.crates.io-6f17d22bba15001f/reqwest-0.12.2/src/async_impl/client.rs:1793:5
     |
1793 |     pub fn new() -> Client {
     |     ^^^^^^^^^^^^^^^^^^^^^^

error[E0277]: the trait bound `HandleError<Route<_>, {closure@examples/eventsub/src/main.rs:133:66: 133:73}, _>: Service<hyper::Request<_>>` is not satisfied
    --> examples/eventsub/src/main.rs:133:66
     |
133  |               get_service(ServeDir::new("./static/")).handle_error(|error| async move {
     |  _____________________________________________________------------_^
     | |                                                     |
     | |                                                     required by a bound introduced by this call
134  | |                 tracing::error!("{}", error);
135  | |                 (
136  | |                     StatusCode::INTERNAL_SERVER_ERROR,
137  | |                     "Unhandled internal error".to_string(),
138  | |                 )
139  | |             }),
     | |_____________^ the trait `Service<hyper::Request<_>>` is not implemented for `HandleError<Route<_>, {closure@examples/eventsub/src/main.rs:133:66: 133:73}, _>`
     |
     = help: the following other types implement trait `Service<Request>`:
               HandleError<S, F, ()>
               HandleError<S, F, (T1,)>
               HandleError<S, F, (T1, T2)>
               HandleError<S, F, (T1, T2, T3)>
               HandleError<S, F, (T1, T2, T3, T4)>
               HandleError<S, F, (T1, T2, T3, T4, T5)>
               HandleError<S, F, (T1, T2, T3, T4, T5, T6)>
               HandleError<S, F, (T1, T2, T3, T4, T5, T6, T7)>
             and 9 others
note: required by a bound in `MethodRouter::<S, B, E>::handle_error`
    --> /home/pajlada/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.6.20/src/routing/method_routing.rs:1055:41
     |
1052 |     pub fn handle_error<F, T>(self, f: F) -> MethodRouter<S, B, Infallible>
     |            ------------ required by a bound in this associated function
...
1055 |         HandleError<Route<B, E>, F, T>: Service<Request<B>, Error = Infallible>,
     |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `MethodRouter::<S, B, E>::handle_error`

error[E0599]: the method `req_get` exists for reference `&HelixClient<'_, Client>`, but its trait bounds were not satisfied
   --> examples/eventsub/src/twitch.rs:266:10
    |
265 |       if let Some(stream) = client
    |  ___________________________-
266 | |         .req_get(
    | |         -^^^^^^^ method cannot be called on `&HelixClient<'_, Client>` due to unsatisfied trait bounds
    | |_________|
    | 
    |
   ::: /home/pajlada/.cargo/registry/src/index.crates.io-6f17d22bba15001f/reqwest-0.12.2/src/async_impl/client.rs:71:1
    |
71  |   pub struct Client {
    |   ----------------- doesn't satisfy `reqwest::Client: HttpClient`
    |
    = note: the following trait bounds were not satisfied:
            `reqwest::Client: HttpClient`

error[E0599]: the method `get_client` exists for struct `HelixClient<'_, Client>`, but its trait bounds were not satisfied
   --> examples/eventsub/src/twitch.rs:249:20
    |
249 |             client.get_client(),
    |                    ^^^^^^^^^^ method cannot be called on `HelixClient<'_, Client>` due to unsatisfied trait bounds
    |
   ::: /home/pajlada/.cargo/registry/src/index.crates.io-6f17d22bba15001f/reqwest-0.12.2/src/async_impl/client.rs:71:1
    |
71  | pub struct Client {
    | ----------------- doesn't satisfy `reqwest::Client: HttpClient`
    |
    = note: the following trait bounds were not satisfied:
            `reqwest::Client: HttpClient`

error[E0599]: the method `get_eventsub_subscriptions` exists for struct `HelixClient<'_, Client>`, but its trait bounds were not satisfied
  --> examples/eventsub/src/twitch.rs:44:14
   |
43 |           let subs = client
   |  ____________________-
44 | |             .get_eventsub_subscriptions(Status::Enabled, None, None, &*token.read().await)
   | |             -^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `HelixClient<'_, Client>` due to unsatisfied trait bounds
   | |_____________|
   | 
   |
  ::: /home/pajlada/.cargo/registry/src/index.crates.io-6f17d22bba15001f/reqwest-0.12.2/src/async_impl/client.rs:71:1
   |
71 |   pub struct Client {
   |   ----------------- doesn't satisfy `reqwest::Client: HttpClient`
   |
   = note: the following trait bounds were not satisfied:
           `reqwest::Client: HttpClient`

error[E0599]: the method `create_eventsub_subscription` exists for struct `HelixClient<'_, Client>`, but its trait bounds were not satisfied
  --> examples/eventsub/src/twitch.rs:98:22
   |
97 | /                 client
98 | |                     .create_eventsub_subscription(
   | |                     -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `HelixClient<'_, Client>` due to unsatisfied trait bounds
   | |_____________________|
   | 
   |
  ::: /home/pajlada/.cargo/registry/src/index.crates.io-6f17d22bba15001f/reqwest-0.12.2/src/async_impl/client.rs:71:1
   |
71 |   pub struct Client {
   |   ----------------- doesn't satisfy `reqwest::Client: HttpClient`
   |
   = note: the following trait bounds were not satisfied:
           `reqwest::Client: HttpClient`

error[E0599]: the method `create_eventsub_subscription` exists for struct `HelixClient<'_, Client>`, but its trait bounds were not satisfied
   --> examples/eventsub/src/twitch.rs:114:22
    |
113 | /                 client
114 | |                     .create_eventsub_subscription(
    | |                     -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `HelixClient<'_, Client>` due to unsatisfied trait bounds
    | |_____________________|
    | 
    |
   ::: /home/pajlada/.cargo/registry/src/index.crates.io-6f17d22bba15001f/reqwest-0.12.2/src/async_impl/client.rs:71:1
    |
71  |   pub struct Client {
    |   ----------------- doesn't satisfy `reqwest::Client: HttpClient`
    |
    = note: the following trait bounds were not satisfied:
            `reqwest::Client: HttpClient`

warning: unused import: `futures::TryStreamExt`
  --> examples/eventsub/src/twitch.rs:10:5
   |
10 | use futures::TryStreamExt;
   |     ^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unused import: `client::ClientDefault`
  --> examples/eventsub/src/main.rs:34:18
   |
34 | use twitch_api::{client::ClientDefault, HelixClient};
   |                  ^^^^^^^^^^^^^^^^^^^^^

Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
warning: `eventsub` (bin "eventsub") generated 2 warnings
error: could not compile `eventsub` (bin "eventsub") due to 7 previous errors; 2 warnings emitted

Output is from https://github.com/twitch-rs/twitch_api/commit/c69d610036d0dce14e58b094281307e813f8fe25 but the same issue occurs on the v0.7.0-rc.7 tag