Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. use hyper::{Body, Error}; // 0.12.27
  2. use hyper::body::Payload;
  3. use hyper::server::conn::AddrIncoming;
  4. use hyper::service::{MakeService, MakeServiceRef, Service};
  5. use futures::future::Future; // 0.1.26
  6. use std::net::SocketAddr;
  7.  
  8. fn check_is_servable<S, B>(_: &S) where
  9. S: MakeServiceRef<AddrIncoming, ReqBody=Body, ResBody=B>,
  10. S::Error: Into<Box<::std::error::Error + Send + Sync>>,
  11. S::Service: 'static,
  12. B: Payload,
  13. {
  14.  
  15. }
  16.  
  17.  
  18. pub fn bind_service<T, S, F>(addr: SocketAddr, make_service: T) -> Result<(), hyper::Error>
  19. where
  20. T: for<'a> MakeService<&'a AddrIncoming, ReqBody = Body, ResBody = Body, Error = Error, MakeError = Error, Service = S, Future = F> + MakeServiceRef<AddrIncoming> + 'static,
  21. S: Service<ReqBody = Body, ResBody = Body, Error = Error> + 'static,
  22. F: Future<Item=S, Error=Error> + Send,
  23. {
  24. check_is_servable(&make_service);
  25.  
  26. Ok(())
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement