Hi,
I was trying to make some web requests using the examples/client.rs file as an example, but it doesn't actually compile. Errors include a handful of non-existent (sub? not sure what to call them in Rust) modules, incorrect function calls, etc.
error[E0412]: cannot find type Uri in module hyper
--> src/main.rs:24:34
|
24 | let url = url.parse::
| ^^^ did you mean Url?
|
= help: there is an enum variant hyper::Error::Uri, did you mean to use hyper::Error?
error[E0061]: this function takes 0 parameters but 1 parameter was supplied
--> src/main.rs:32:30
|
32 | let client = Client::new(&handle);
| ^^^^^^^ expected 0 parameters
error: no method named and_then found for type hyper::client::RequestBuilder<'_> in the current scope
--> src/main.rs:34:32
|
34 | let work = client.get(url).and_then(|res| {
| ^^^^^^^^
|
= note: the method and_then exists but the following trait bounds were not satisfied: hyper::client::RequestBuilder<'_> : futures::Stream, hyper::client::RequestBuilder<'_> : futures::Future
error[E0277]: the trait bound [u8]: std::marker::Sized is not satisfied
--> src/main.rs:38:30
|
38 | res.body().for_each(|chunk| {
| ^^^^^ the trait std::marker::Sized is not implemented for [u8]
|
= note: [u8] does not have a constant size known at compile-time
= note: all local variables must have a statically known size
Looking at the error messages, it looks like you have hyper 0.10.x from crates.io, but the examples in master in this repo are using a largely redesigned hyper.
Proposing this issue can be closed.
@Hoverbear: Before closing, can you please add a conspicuous warning message to the examples to warn about the version incompatibility? Thanks!
I was about to ask why https://github.com/hyperium/hyper/blob/12d01e402363a1d7432e878ad43e6345a29e7a21/examples/hello.rs mismatches the current API docs at https://hyper.rs/hyper/v0.10.9/hyper/server/index.html .
@sanmai-NL I encourage you to make a PR! :)
A release should happen next week, I don't think the confusion would happen for much longer.
Confusion still happens with hyper 0.11.25:
error[E0599]: no method named `and_then` found for type `hyper::client::FutureResponse` in the current scope
--> src/service_client.rs:69:14
|
69 | .and_then(|res| {
| ^^^^^^^^
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
candidate #1: `use futures::future::Future;`
Even though I have use futures::future::Future; in the file, this happens with futures 0.2.0.
With futures 0.1.21 it does similarly bad things:
error[E0277]: the trait bound `(): futures::Future` is not satisfied
--> src/service_client.rs:69:14
|
69 | .and_then(|res| {
| ^^^^^^^^ the trait `futures::Future` is not implemented for `()`
|
= note: required because of the requirements on the impl of `futures::IntoFuture` for `()`
@berkus hyper uses futures 0.1 at the moment. I'd recommend using that yourself, unless really wanting live on the bleeding (slash crying) edge, in which case you could try to use the futures-compat crate.
@seanmonstar yeah, i've been trying to live on the crying edge today, and it seems painful. Thanks for the update. I learned many new things today.
Most helpful comment
A release should happen next week, I don't think the confusion would happen for much longer.