Hi,
In my application, I need to tightly control the threads spawned, so I want to use my own runtime for futures.
Disabling the default features (which appears to only be the runtime) like this:
[dependencies.hyper]
version = "0.12"
default-features = false
Raises the following error at compile-time:
error[E0599]: no function or associated item named `new` found for type `hyper::Client<_, _>` in the current scope
--> src/main.rs:32:18
|
32 | let client = hyper::Client::new();
| ^^^^^^^^^^^^^^^^^^ function or associated item not found in `hyper::Client<_, _>`
Cargo:
$ cargo 1.30.0-nightly (b917e3524 2018-09-09)
Am I missing something here?
Disclaimer - I've not used Hyper, so this is purely based on me digging through the source code 
Client
has a generic parameter, C
, which needs to be an implementation of Connect
. If you look at the part of the code where Client::new()
is defined, you'll notice that it's only defined where C
is HttpConnector
- this connector is what the client uses to talk to the runtime, so without the runtime enabled, it doesn't exist!
In order to use your own custom runtime, you'd need to write your own connector for it (which implements Connect
), and then use the Builder
to link that with a new instance of Client
.
Thanks. I also noticed that even the impl which holds the new
method is behind the runtime
feature. I think this makes hyper without a runtime
rather pointless but answers my question.