I want to get a hyper::Client
configured according to the URL scheme. For that, I created a small method:
extern crate http; // 0.1.8
extern crate hyper; // 0.12.7
extern crate hyper_tls; // 0.1.4
use http::uri::Scheme;
use hyper::{Body, Client, Uri};
use hyper_tls::HttpsConnector;
#[derive(Clone, Debug)]
pub struct Feed;
impl Feed {
fn get_client(uri: Uri) -> Client {
match uri.scheme_part() {
Some(Scheme::HTTP) => Client::new(),
Some(Scheme::HTTPS) => {
let https = HttpsConnector::new(4).expect("TLS initialization failed");
let client = Client::builder().build::<_, Body>(https);
}
_ => panic!("We don't support schemes other than HTTP/HTTPS"),
}
}
}
When I try to compile it, I get this error message:
error[E0243]: wrong number of type arguments: expected at least 1, found 0
--> src/main.rs:13:32
|
13 | fn get_client(uri: Uri) -> Client {
| ^^^^^^ expected at least 1 type argument
I don't understand why it doesn't compile since
- I've declared my use of the hyper crate in my main.rs
- I declare my use in file header
What am I doing wrong ?