blob: b51494a88280565ef52d6f37e5b70483debffc22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
use hyper::service::Service;
use std::{
future::{ready, Ready},
task::{Context, Poll},
};
pub struct MakeSvc<T: Clone> {
pub service: T,
}
impl<T, V: Clone> Service<T> for MakeSvc<V> {
type Response = V;
type Error = std::io::Error;
type Future = Ready<Result<Self::Response, Self::Error>>;
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Ok(()).into()
}
fn call(&mut self, _: T) -> Self::Future {
ready(Ok(self.service.clone()))
}
}
impl<T: Clone> MakeSvc<T> {
pub fn new(service: T) -> Self {
Self { service }
}
}
|