Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reqwest-middleware 0.2 breaks RVCR #5

Closed
Mattsi-Jansky opened this issue Jun 5, 2023 · 3 comments · Fixed by #15
Closed

reqwest-middleware 0.2 breaks RVCR #5

Mattsi-Jansky opened this issue Jun 5, 2023 · 3 comments · Fixed by #15

Comments

@Mattsi-Jansky
Copy link

So I got a bit further this time but it seems there is some API change in reqwest-middleware version 0.2 that breaks RVCR. I got further with 0.1.6 but on 0.2 onwards I get the following type error when trying to follow the example:

code:

  let middleware: VCRMiddleware = VCRMiddleware::try_from(bundle.clone())
      .unwrap()
      .with_mode(VCRMode::Record);

  let vcr_client: ClientWithMiddleware = ClientBuilder::new(reqwest::Client::new())
      .with(middleware) //<< error occurs here
      .build();

output:

error[E0277]: expected a `Fn<(Request, &'a mut task_local_extensions::extensions::Extensions, Next<'a>)>` closure, found `VCRMiddleware`
  --> framework/tests/acceptance.rs:19:15
   |
19 |         .with(middleware)
   |          ---- ^^^^^^^^^^ expected an `Fn<(Request, &'a mut task_local_extensions::extensions::Extensions, Next<'a>)>` closure, found `VCRMiddleware`
   |          |
   |          required by a bound introduced by this call
   |
   = help: the trait `for<'a> Fn<(Request, &'a mut task_local_extensions::extensions::Extensions, Next<'a>)>` is not implemented for `VCRMiddleware`
   = note: required for `VCRMiddleware` to implement `reqwest_middleware::Middleware`

I'm not totally sure what's going on here. The Middleware trait still exists in the latest sourcecode for reqwest-middleware and is specified in that function, M must implement Middleware. I'm guessing that the definition of Middleware has changed, and this compiler output is a bit misleading.

@mksh
Copy link
Contributor

mksh commented Jun 9, 2023

Hmm, I haven't tested it with 0.2 yet. Will be able to test it next week, there were some API changes definitely.

@QAston
Copy link
Contributor

QAston commented Jun 11, 2023

Different 0.x versions are not compatible for the rust semver dependency resolver, so if there's an implementation for 0.1 and you use 0.2 in your code rustc will complain even if the code didn't change, try using a branch of rvcr with 0.2 set, that will make the situation clearer.

@jtran
Copy link
Contributor

jtran commented Feb 5, 2024

The error seems to be caused by rvcr using v0.1 while your code uses v0.2 of reqwest-middleware. I.e. differing versions cause the error. The versions should match. Please check out #15. Thank you.

@mksh mksh closed this as completed in #15 Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants