@@ -29,7 +29,7 @@ pub(crate) fn parse_names<T: Stream<Item = io::Result<ResponseData>> + Unpin + S
29
29
Some ( Ok ( name) )
30
30
}
31
31
_ => {
32
- handle_unilateral ( resp, unsolicited) . await ;
32
+ handle_unilateral ( resp, unsolicited) ;
33
33
None
34
34
}
35
35
} ,
@@ -79,7 +79,7 @@ pub(crate) fn parse_fetches<T: Stream<Item = io::Result<ResponseData>> + Unpin +
79
79
Ok ( resp) => match resp. parsed ( ) {
80
80
Response :: Fetch ( ..) => Some ( Ok ( Fetch :: new ( resp) ) ) ,
81
81
_ => {
82
- handle_unilateral ( resp, unsolicited) . await ;
82
+ handle_unilateral ( resp, unsolicited) ;
83
83
None
84
84
}
85
85
} ,
@@ -157,7 +157,7 @@ pub(crate) async fn parse_status<T: Stream<Item = io::Result<ResponseData>> + Un
157
157
}
158
158
}
159
159
_ => {
160
- handle_unilateral ( resp, unsolicited. clone ( ) ) . await ;
160
+ handle_unilateral ( resp, unsolicited. clone ( ) ) ;
161
161
}
162
162
}
163
163
}
@@ -182,7 +182,7 @@ pub(crate) fn parse_expunge<T: Stream<Item = io::Result<ResponseData>> + Unpin +
182
182
Ok ( resp) => match resp. parsed ( ) {
183
183
Response :: Expunge ( id) => Some ( Ok ( * id) ) ,
184
184
_ => {
185
- handle_unilateral ( resp, unsolicited) . await ;
185
+ handle_unilateral ( resp, unsolicited) ;
186
186
None
187
187
}
188
188
} ,
@@ -213,7 +213,7 @@ pub(crate) async fn parse_capabilities<T: Stream<Item = io::Result<ResponseData>
213
213
}
214
214
}
215
215
_ => {
216
- handle_unilateral ( resp, unsolicited. clone ( ) ) . await ;
216
+ handle_unilateral ( resp, unsolicited. clone ( ) ) ;
217
217
}
218
218
}
219
219
}
@@ -232,7 +232,7 @@ pub(crate) async fn parse_noop<T: Stream<Item = io::Result<ResponseData>> + Unpi
232
232
. await
233
233
{
234
234
let resp = resp?;
235
- handle_unilateral ( resp, unsolicited. clone ( ) ) . await ;
235
+ handle_unilateral ( resp, unsolicited. clone ( ) ) ;
236
236
}
237
237
238
238
Ok ( ( ) )
@@ -338,7 +338,7 @@ pub(crate) async fn parse_mailbox<T: Stream<Item = io::Result<ResponseData>> + U
338
338
}
339
339
}
340
340
Response :: MailboxData ( m) => match m {
341
- MailboxDatum :: Status { .. } => handle_unilateral ( resp, unsolicited. clone ( ) ) . await ,
341
+ MailboxDatum :: Status { .. } => handle_unilateral ( resp, unsolicited. clone ( ) ) ,
342
342
MailboxDatum :: Exists ( e) => {
343
343
mailbox. exists = * e;
344
344
}
@@ -358,7 +358,7 @@ pub(crate) async fn parse_mailbox<T: Stream<Item = io::Result<ResponseData>> + U
358
358
_ => { }
359
359
} ,
360
360
_ => {
361
- handle_unilateral ( resp, unsolicited. clone ( ) ) . await ;
361
+ handle_unilateral ( resp, unsolicited. clone ( ) ) ;
362
362
}
363
363
}
364
364
}
@@ -386,7 +386,7 @@ pub(crate) async fn parse_ids<T: Stream<Item = io::Result<ResponseData>> + Unpin
386
386
}
387
387
}
388
388
_ => {
389
- handle_unilateral ( resp, unsolicited. clone ( ) ) . await ;
389
+ handle_unilateral ( resp, unsolicited. clone ( ) ) ;
390
390
}
391
391
}
392
392
}
@@ -421,7 +421,7 @@ pub(crate) async fn parse_metadata<T: Stream<Item = io::Result<ResponseData>> +
421
421
// [Unsolicited METADATA Response without Values](https://datatracker.ietf.org/doc/html/rfc5464.html#section-4.4.2),
422
422
// they go to unsolicited channel with other unsolicited responses.
423
423
_ => {
424
- handle_unilateral ( resp, unsolicited. clone ( ) ) . await ;
424
+ handle_unilateral ( resp, unsolicited. clone ( ) ) ;
425
425
}
426
426
}
427
427
}
@@ -430,48 +430,30 @@ pub(crate) async fn parse_metadata<T: Stream<Item = io::Result<ResponseData>> +
430
430
431
431
// check if this is simply a unilateral server response
432
432
// (see Section 7 of RFC 3501):
433
- pub ( crate ) async fn handle_unilateral (
433
+ pub ( crate ) fn handle_unilateral (
434
434
res : ResponseData ,
435
435
unsolicited : channel:: Sender < UnsolicitedResponse > ,
436
436
) {
437
- // ignore these if they are not being consumed
438
- if unsolicited. is_full ( ) {
439
- return ;
440
- }
441
-
442
437
match res. parsed ( ) {
443
438
Response :: MailboxData ( MailboxDatum :: Status { mailbox, status } ) => {
444
439
unsolicited
445
- . send ( UnsolicitedResponse :: Status {
440
+ . try_send ( UnsolicitedResponse :: Status {
446
441
mailbox : ( mailbox. as_ref ( ) ) . into ( ) ,
447
442
attributes : status. to_vec ( ) ,
448
443
} )
449
- . await
450
- . expect ( "Channel closed unexpectedly" ) ;
444
+ . ok ( ) ;
451
445
}
452
446
Response :: MailboxData ( MailboxDatum :: Recent ( n) ) => {
453
- unsolicited
454
- . send ( UnsolicitedResponse :: Recent ( * n) )
455
- . await
456
- . expect ( "Channel closed unexpectedly" ) ;
447
+ unsolicited. try_send ( UnsolicitedResponse :: Recent ( * n) ) . ok ( ) ;
457
448
}
458
449
Response :: MailboxData ( MailboxDatum :: Exists ( n) ) => {
459
- unsolicited
460
- . send ( UnsolicitedResponse :: Exists ( * n) )
461
- . await
462
- . expect ( "Channel closed unexpectedly" ) ;
450
+ unsolicited. try_send ( UnsolicitedResponse :: Exists ( * n) ) . ok ( ) ;
463
451
}
464
452
Response :: Expunge ( n) => {
465
- unsolicited
466
- . send ( UnsolicitedResponse :: Expunge ( * n) )
467
- . await
468
- . expect ( "Channel closed unexpectedly" ) ;
453
+ unsolicited. try_send ( UnsolicitedResponse :: Expunge ( * n) ) . ok ( ) ;
469
454
}
470
455
_ => {
471
- unsolicited
472
- . send ( UnsolicitedResponse :: Other ( res) )
473
- . await
474
- . expect ( "Channel closed unexpectedly" ) ;
456
+ unsolicited. try_send ( UnsolicitedResponse :: Other ( res) ) . ok ( ) ;
475
457
}
476
458
}
477
459
}
0 commit comments