use super::{HttpService, Service}; use crate::body::HttpBody; use crate::common::{task, Future, Poll}; use std::error::Error as StdError; use std::fmt; use tokio::io::{AsyncRead, AsyncWrite}; pub(crate) trait MakeConnection: self::sealed::Sealed<(Target,)> { type Connection: AsyncRead + AsyncWrite; type Error; type Future: Future>; fn poll_ready(&mut self, cx: &mut task::Context<'_>) -> Poll>; fn make_connection(&mut self, target: Target) -> Self::Future; } impl self::sealed::Sealed<(Target,)> for S where S: Service {} impl MakeConnection for S where S: Service, S::Response: AsyncRead + AsyncWrite, { type Connection = S::Response; type Error = S::Error; type Future = S::Future; fn poll_ready(&mut self, cx: &mut task::Context<'_>) -> Poll> { loop {} } fn make_connection(&mut self, target: Target) -> Self::Future { loop {} } } pub trait MakeServiceRef { type ResBody; type Error; type Service: HttpService; } impl MakeServiceRef for T where T: for<'a> Service<&'a Target, Error = ME, Response = S, Future = F>, E: Into>, ME: Into>, S: HttpService, F: Future>, IB: HttpBody, OB: HttpBody, { type Error = E; type Service = S; type ResBody = OB; } impl self::sealed::Sealed<(Target, B1)> for T where T: for<'a> Service<&'a Target, Response = S>, S: HttpService, B1: HttpBody, B2: HttpBody, { } pub fn make_service_fn(f: F) -> MakeServiceFn where F: FnMut(&Target) -> Ret, Ret: Future, { loop {} } #[derive(Clone, Copy)] pub struct MakeServiceFn { f: F, } impl<'t, F, Ret, Target, Svc, MkErr> Service<&'t Target> for MakeServiceFn where F: FnMut(&Target) -> Ret, Ret: Future>, MkErr: Into>, { type Error = MkErr; type Response = Svc; type Future = Ret; fn poll_ready(&mut self, _cx: &mut task::Context<'_>) -> Poll> { loop {} } fn call(&mut self, target: &'t Target) -> Self::Future { loop {} } } impl fmt::Debug for MakeServiceFn { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { loop {} } } mod sealed { pub trait Sealed {} #[allow(unreachable_pub)] pub trait CantImpl {} #[allow(missing_debug_implementations)] pub enum CantName {} impl CantImpl for CantName {} }