Advertisement
Guest User

Untitled

a guest
Jan 1st, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 1.21 KB | None | 0 0
  1. ================= cargo build error
  2. error[E0271]: type mismatch resolving `<MetricServer as hyper::client::Service>::Error == hyper::Error`
  3.   --> metrics/src/lib.rs:30:38
  4.    |
  5. 30 |         let mut server = Http::new().bind(&addr, || Ok(MetricServer)).unwrap();
  6.    |                                      ^^^^ expected struct `failure::Error`, found enum `hyper::Error`
  7.    |
  8.    = note: expected type `failure::Error`
  9.               found type `hyper::Error`
  10.  
  11. error: aborting due to previous error
  12.  
  13. error: Could not compile `metrics`.
  14.  
  15. ================= relevant code snippet:
  16. fn init() {
  17.     thread::spawn(|| {
  18.         let addr = "127.0.0.1:9898".parse().unwrap();
  19.         let mut server = Http::new().bind(&addr, || Ok(MetricServer)).unwrap();  <-- error here
  20.     });
  21. }
  22.  
  23. impl MetricServer {
  24.     fn metric_response(&self, req: Request) -> std::result::Result<Response, failure::Error> {
  25.       ...    
  26.     }
  27. }
  28.  
  29. impl Service for MetricServer {
  30.     type Request = Request;
  31.     type Response = Response;
  32.     type Error = failure::Error;
  33.     type Future = FutureResult<Response, failure::Error>;
  34.     fn call(&self, req: Request) -> Self::Future {
  35.         futures::future::result(self.metric_response(req))
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement