@@ -134,7 +134,9 @@ impl StunAgent {
134
134
send_data ( self . transport , bytes, self . local_addr , to)
135
135
}
136
136
137
- /// Perform any operations needed to be able to send a [`Message`] to a peer
137
+ /// Perform any operations needed to be able to send a [`Message`] to a peer.
138
+ ///
139
+ /// If a request message is successfully sent, then [`StunAgent::poll`] needs to be called.
138
140
pub fn send ( & mut self , msg : Message , to : SocketAddr ) -> Result < Transmit < ' _ > , StunError > {
139
141
let data = msg. to_bytes ( ) ;
140
142
if msg. has_class ( MessageClass :: Request ) {
@@ -185,7 +187,8 @@ impl StunAgent {
185
187
/// Provide data received on a socket from a peer for handling by the [`StunAgent`].
186
188
/// The returned value indicates what the caller must do with the data.
187
189
///
188
- /// After this call, any outstanding [`StunRequest`] may need to be `poll()`ed again.
190
+ /// If this function returns [`HandleStunReply::StunResponse`], then this agent needs to be
191
+ /// `poll()`ed again.
189
192
#[ tracing:: instrument(
190
193
name = "stun_incoming_data"
191
194
level = "info" ,
@@ -303,7 +306,10 @@ impl StunAgent {
303
306
}
304
307
}
305
308
306
- /// Retrieve a reference to an outstanding STUN request
309
+ /// Retrieve a reference to an outstanding STUN request. Outstanding requests are kept until
310
+ /// either `handle_incoming_data` receives the associated response, or `poll()` returns
311
+ /// [`StunAgentPollRet::TransactionCancelled`] or a [`StunAgentPollRet::TransactionTimedOut`]
312
+ /// for the request.
307
313
pub fn request_transaction ( & self , transaction_id : TransactionId ) -> Option < StunRequest > {
308
314
if self . outstanding_requests . contains_key ( & transaction_id) {
309
315
Some ( StunRequest {
@@ -315,7 +321,10 @@ impl StunAgent {
315
321
}
316
322
}
317
323
318
- /// Retrieve a mutable reference to an outstanding STUN request
324
+ /// Retrieve a mutable reference to an outstanding STUN request. Outstanding requests are kept
325
+ /// until either `handle_incoming_data` receives the associated response, or `poll()` returns
326
+ /// [`StunAgentPollRet::TransactionCancelled`] or a [`StunAgentPollRet::TransactionTimedOut`]
327
+ /// for the request.
319
328
pub fn mut_request_transaction (
320
329
& mut self ,
321
330
transaction_id : TransactionId ,
@@ -341,7 +350,7 @@ impl StunAgent {
341
350
self . outstanding_requests . get ( & transaction_id)
342
351
}
343
352
344
- /// Poll the agent for making further progress on any outstanding requests. The returned value
353
+ /// Poll the agent for making further progress on any outstanding requests. The returned value
345
354
/// indicates the current state and anything the caller needs to perform.
346
355
#[ tracing:: instrument(
347
356
name = "stun_request_poll"
@@ -391,9 +400,9 @@ impl StunAgent {
391
400
/// Return value for [`StunAgent::poll`]
392
401
#[ derive( Debug ) ]
393
402
pub enum StunAgentPollRet < ' a > {
394
- /// An oustanding transaction timed out.
403
+ /// An oustanding transaction timed out and has been removed from the agent .
395
404
TransactionTimedOut ( Message ) ,
396
- /// An oustanding transaction was cancelled.
405
+ /// An oustanding transaction was cancelled and has been removed from the agent .
397
406
TransactionCancelled ( Message ) ,
398
407
/// Send data using the specified 5-tuple
399
408
SendData ( Transmit < ' a > ) ,
0 commit comments