@@ -520,15 +520,14 @@ impl Connection {
520520
521521 /// Wait for the connection to be closed without keeping a strong reference to the connection
522522 ///
523+ /// Returns a future that resolves, once the connection is closed, to a tuple of
524+ /// ([`ConnectionError`], [`ConnectionStats`]).
525+ ///
523526 /// Calling [`Self::closed`] keeps the connection alive until it is either closed locally via [`Connection::close`]
524- /// or closed by the remote peer. This function instead does not keep a reference to the connection itself,
527+ /// or closed by the remote peer. This function instead does not keep the connection itself alive ,
525528 /// so if all *other* clones of the connection are dropped, the connection will be closed implicitly even
526529 /// if there are futures returned from this function still being awaited.
527- ///
528- /// Returns the reason why the connection was closed and the final [`ConnectionStats`].
529- pub fn on_closed (
530- & self ,
531- ) -> impl Future < Output = ( ConnectionError , ConnectionStats ) > + Send + Sync + ' static {
530+ pub fn on_closed ( & self ) -> OnClosed {
532531 let ( tx, rx) = oneshot:: channel ( ) ;
533532 self . 0 . state . lock ( "on_closed" ) . on_closed . push ( tx) ;
534533 OnClosed {
@@ -1056,12 +1055,14 @@ impl Future for SendDatagram<'_> {
10561055 }
10571056}
10581057
1059- struct OnClosed {
1058+ /// Future returned by [`Connection::on_closed`]
1059+ ///
1060+ /// Resolves to a tuple of ([`ConnectionError`], [`ConnectionStats`]).
1061+ pub struct OnClosed {
10601062 rx : oneshot:: Receiver < ( ConnectionError , ConnectionStats ) > ,
10611063 conn : WeakConnectionHandle ,
10621064}
10631065
1064- /// Future returned by [`Connection::on_closed`]
10651066impl Drop for OnClosed {
10661067 fn drop ( & mut self ) {
10671068 if self . rx . is_terminated ( ) {
0 commit comments