1- use core:: future:: Future ;
21use no_std_net:: SocketAddr ;
32
43/// This trait is implemented by TCP/IP stacks. The trait allows the underlying driver to
@@ -10,29 +9,29 @@ pub trait TcpConnect {
109 type Error : embedded_io:: Error ;
1110
1211 /// Type holding state of a TCP connection. Should close the connection when dropped.
13- type Connection < ' m > : embedded_io:: asynch:: Read < Error = Self :: Error >
12+ type Connection < ' a > : embedded_io:: asynch:: Read < Error = Self :: Error >
1413 + embedded_io:: asynch:: Write < Error = Self :: Error >
1514 where
16- Self : ' m ;
17- /// Future returned by `connect` function.
18- type ConnectFuture < ' m > : Future < Output = Result < Self :: Connection < ' m > , Self :: Error > > + ' m
19- where
20- Self : ' m ;
15+ Self : ' a ;
2116
2217 /// Connect to the given remote host and port.
2318 ///
2419 /// Returns `Ok` if the connection was successful.
25- fn connect < ' m > ( & ' m self , remote : SocketAddr ) -> Self :: ConnectFuture < ' m > ;
20+ async fn connect < ' a > ( & ' a self , remote : SocketAddr ) -> Result < Self :: Connection < ' a > , Self :: Error >
21+ // This bound is required due to an AFIT limitaton: https://github.com/rust-lang/rust/issues/104908
22+ where
23+ Self : ' a ;
2624}
2725
2826impl < T : TcpConnect > TcpConnect for & T {
2927 type Error = T :: Error ;
3028
31- type Connection < ' m > = T :: Connection < ' m > where Self : ' m ;
29+ type Connection < ' a > = T :: Connection < ' a > where Self : ' a ;
3230
33- type ConnectFuture < ' m > = T :: ConnectFuture < ' m > where Self : ' m ;
34-
35- fn connect < ' m > ( & ' m self , remote : SocketAddr ) -> Self :: ConnectFuture < ' m > {
36- T :: connect ( self , remote)
31+ async fn connect < ' a > ( & ' a self , remote : SocketAddr ) -> Result < Self :: Connection < ' a > , Self :: Error >
32+ where
33+ Self : ' a ,
34+ {
35+ T :: connect ( self , remote) . await
3736 }
3837}
0 commit comments