@@ -27,10 +27,12 @@ use no_std_net::SocketAddr;
27
27
/// `bind()` call in the creation of such sockets, these are implicitly bound to a suitable local
28
28
/// address at connect time.
29
29
pub trait ConnectedUdp {
30
+ /// Error type returned by send and receive operations.
30
31
type Error : embedded_io:: Error ;
31
32
32
33
/// Send the provided data to the connected peer
33
34
fn send ( & mut self , data : & [ u8 ] ) -> Self :: SendFuture < ' _ > ;
35
+ /// Return type of the [`.send()`] method
34
36
type SendFuture < ' a > : Future < Output = Result < ( ) , Self :: Error > >
35
37
where
36
38
Self : ' a ;
@@ -47,6 +49,7 @@ pub trait ConnectedUdp {
47
49
/// (a possibility not considered there). The name deviates from the original `receive()` to
48
50
/// make room for a version that is more zero-copy friendly.
49
51
fn receive_into ( & mut self , buffer : & mut [ u8 ] ) -> Self :: ReceiveIntoFuture < ' _ > ;
52
+ /// Return type of the [`.receive_into()`] method
50
53
type ReceiveIntoFuture < ' a > : Future < Output = Result < usize , Self :: Error > >
51
54
where
52
55
Self : ' a ;
@@ -71,6 +74,7 @@ pub trait ConnectedUdp {
71
74
/// caller MUST pass in the same (or compatible) values, MAY and pass in unspecified values where
72
75
/// applicable. The implementer MAY check them for compatibility, and SHOULD do that in debug mode.
73
76
pub trait UnconnectedUdp {
77
+ /// Error type returned by send and receive operations.
74
78
type Error : embedded_io:: Error ;
75
79
76
80
/// Send the provided data to a peer
@@ -90,13 +94,14 @@ pub trait UnconnectedUdp {
90
94
/// address. Both are valid choices in some situations, and the right choice depends on the
91
95
/// protocol used.
92
96
///
93
- /// Note that users of sockets created through [`UdpSocket ::bind_single()`] should always pass
97
+ /// Note that users of sockets created through [`UdpStack ::bind_single()`] should always pass
94
98
/// in that single address -- even though they've made their intention clear at construction.
95
99
/// They can pass either the one obtained at socket creation time, or the one obtained at
96
100
/// receive time; these should be equal. This allows implementations of the trait to use a
97
101
/// single kind of socket for both sockets bound to a single and sockets bound to multiple
98
102
/// addresses.
99
103
fn send ( & mut self , local : SocketAddr , remote : SocketAddr , data : & [ u8 ] ) -> Self :: SendFuture < ' _ > ;
104
+ /// Return type of the [`.send()`] method
100
105
type SendFuture < ' a > : Future < Output = Result < ( ) , Self :: Error > >
101
106
where
102
107
Self : ' a ;
@@ -109,9 +114,11 @@ pub trait UnconnectedUdp {
109
114
///
110
115
/// The local and remote address are given, in that order, in the result along with the number
111
116
/// of bytes.
112
- fn receive ( & mut self , buffer : & mut [ u8 ] ) -> Self :: ReceiveFuture < ' _ > ;
113
- type ReceiveFuture < ' a > : Future < Output = Result < ( usize , SocketAddr , SocketAddr ) , Self :: Error > >
114
- where
117
+ fn receive_into ( & mut self , buffer : & mut [ u8 ] ) -> Self :: ReceiveIntoFuture < ' _ > ;
118
+ /// Return type of the [`.receive_into()`] method
119
+ type ReceiveIntoFuture < ' a > : Future <
120
+ Output = Result < ( usize , SocketAddr , SocketAddr ) , Self :: Error > ,
121
+ > where
115
122
Self : ' a ;
116
123
}
117
124
@@ -124,12 +131,15 @@ pub trait UdpStack {
124
131
/// Error type returned on socket creation failure.
125
132
type Error : embedded_io:: Error ;
126
133
134
+ /// Eventual socket return type of the [`.connect()`] method
127
135
type Connected < ' m > : ConnectedUdp
128
136
where
129
137
Self : ' m ;
138
+ /// Eventual socket return type of the [`.bind_single()`] method
130
139
type Bound < ' m > : UnconnectedUdp
131
140
where
132
141
Self : ' m ;
142
+ /// Eventual return type of the [`.bind_multiple()`] method
133
143
type Unbound < ' m > : UnconnectedUdp
134
144
where
135
145
Self : ' m ;
@@ -140,8 +150,9 @@ pub trait UdpStack {
140
150
///
141
151
/// While asynchronous traits implemented through GAT can not have provided default methods,
142
152
/// implementers are encouraged to use the hidden `.connect_default()` method if all they would
143
- /// do is delegating to [`connect_from`] with a suitable unspecified local address.
153
+ /// do is delegating to [`. connect_from`] with a suitable unspecified local address.
144
154
fn connect ( & self , remote : SocketAddr ) -> Self :: ConnectFuture < ' _ > ;
155
+ /// Future return type of the [`.connect()`] method
145
156
type ConnectFuture < ' a > : Future < Output = Result < ( SocketAddr , Self :: Connected < ' a > ) , Self :: Error > >
146
157
where
147
158
Self : ' a ;
@@ -152,6 +163,7 @@ pub trait UdpStack {
152
163
/// network stack at connection time. The full local address is returned along with the
153
164
/// connected socket, primarily for debugging purposes.
154
165
fn connect_from ( & self , local : SocketAddr , remote : SocketAddr ) -> Self :: ConnectFromFuture < ' _ > ;
166
+ /// Future return type of the [`.connect_from()`] method
155
167
type ConnectFromFuture < ' a > : Future <
156
168
Output = Result < ( SocketAddr , Self :: Connected < ' a > ) , Self :: Error > ,
157
169
> where
@@ -178,6 +190,7 @@ pub trait UdpStack {
178
190
/// The full local address is returned along with the bound socket; it may then be passed on to
179
191
/// other protocols for advertising purposes.
180
192
fn bind_single ( & self , local : SocketAddr ) -> Self :: BindSingleFuture < ' _ > ;
193
+ /// Future return type of the [`.bind_single()`] method
181
194
type BindSingleFuture < ' a > : Future < Output = Result < ( SocketAddr , Self :: Bound < ' a > ) , Self :: Error > >
182
195
where
183
196
Self : ' a ;
@@ -205,6 +218,7 @@ pub trait UdpStack {
205
218
/// binding to `[::]:0`, that is, picking some available port but then still leaving the
206
219
/// interface and IP address unspecified.
207
220
fn bind_multiple ( & self , local : SocketAddr ) -> Self :: BindMultipleFuture < ' _ > ;
221
+ /// Future return type of the [`.bind_multiple()`] method
208
222
type BindMultipleFuture < ' a > : Future < Output = Result < Self :: Unbound < ' a > , Self :: Error > >
209
223
where
210
224
Self : ' a ;
0 commit comments