tower_async/make/
make_connection.rs1use crate::sealed::Sealed;
2use tokio::io::{AsyncRead, AsyncWrite};
3use tower_async_service::Service;
4
5pub trait MakeConnection<Target>: Sealed<(Target,)> {
11 type Connection: AsyncRead + AsyncWrite;
13
14 type Error;
16
17 fn make_connection(
19 &self,
20 target: Target,
21 ) -> impl std::future::Future<Output = Result<Self::Connection, Self::Error>>;
22}
23
24impl<S, Target> Sealed<(Target,)> for S where S: Service<Target> {}
25
26impl<C, Target> MakeConnection<Target> for C
27where
28 C: Service<Target>,
29 C::Response: AsyncRead + AsyncWrite,
30{
31 type Connection = C::Response;
32 type Error = C::Error;
33
34 async fn make_connection(&self, target: Target) -> Result<Self::Connection, Self::Error> {
35 Service::call(self, target).await
36 }
37}