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
30
31
32
33
34
35
36
37
use no_std_net::SocketAddr;
pub trait TcpConnect {
type Error: embedded_io::Error;
type Connection<'a>: embedded_io::asynch::Read<Error = Self::Error>
+ embedded_io::asynch::Write<Error = Self::Error>
where
Self: 'a;
async fn connect<'a>(&'a self, remote: SocketAddr) -> Result<Self::Connection<'a>, Self::Error>
where
Self: 'a;
}
impl<T: TcpConnect> TcpConnect for &T {
type Error = T::Error;
type Connection<'a> = T::Connection<'a> where Self: 'a;
async fn connect<'a>(&'a self, remote: SocketAddr) -> Result<Self::Connection<'a>, Self::Error>
where
Self: 'a,
{
T::connect(self, remote).await
}
}