Created
December 14, 2018 20:22
-
-
Save LucioFranco/4372bcb6ebb3f180324ac1def7129f86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use tower_service::Service; | |
use futures::Future; | |
use tokio_io::{AsyncRead, AsyncWrite}; | |
use std::net::ToSocketAddrs; | |
pub trait ConnectService<A: ToSocketAddrs>{ | |
type Response: AsyncRead + AsyncWrite; | |
type Error; | |
type Service: Service<A>; | |
type Future: Future<Item = Self::Response, Error = Self::Error>; | |
fn connect(&self, target: A) -> Self::Future; | |
} | |
impl<A, S, C, Request> ConnectService<A> for C | |
where A: ToSocketAddrs, | |
C: Service<A>, | |
C::Response: AsyncRead + AsyncWrite, | |
S: Service<Request>, | |
{ | |
type Response = C::Response; | |
type Error = S::Error; | |
type Service = S; | |
type Error = C::Error; | |
type Future = C::Future; | |
fn connect(&mut self, target: A) -> Self::Future { | |
ConnectService::connect(self, target) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment