From 1fdd6904476cd46fd14bbe1cefdcd3f819ea048c Mon Sep 17 00:00:00 2001 From: zphrs Date: Tue, 17 Mar 2026 06:24:08 -0700 Subject: [PATCH] docs(quinn): improve `Connection::close_reason()` documentation (cherry picked from commit f0905db64178771a62c433c8b0b0e095dfaa8f66) --- noq/src/connection.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/noq/src/connection.rs b/noq/src/connection.rs index cb3aec858..f7d9a5dca 100644 --- a/noq/src/connection.rs +++ b/noq/src/connection.rs @@ -582,9 +582,14 @@ impl Connection { } } - /// If the connection is closed, the reason why. + /// Whether the connection is closed, and why. /// - /// Returns `None` if the connection is still open. + /// The close_reason is always set to `Some(ConnectionError)` when a socket is + /// closed; whether it was closed manually by calling [`Connection::close()`] or due to + /// an internal error (such as an idle timeout or the peer closing the + /// connection). + /// + /// Note: when the connection is closed, `connection.close_reason().is_some()` will always be true. pub fn close_reason(&self) -> Option { self.0.lock_without_waking("close_reason").error.clone() }