From bea41016889532897765e166d0ac7f4fb15cedbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sosth=C3=A8ne=20Gu=C3=A9don?= Date: Fri, 31 Jan 2025 17:30:31 +0100 Subject: [PATCH] Make Duration::not_zero public. This is useful for downstream wanting to re-implement `TcpTransport` This struct is only ever exposed through the `unversionned` module so its fine to expose this method and remove it in the future --- src/timings.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/timings.rs b/src/timings.rs index f4b2b434..8a29a6ef 100644 --- a/src/timings.rs +++ b/src/timings.rs @@ -180,7 +180,10 @@ pub struct NextTimeout { } impl NextTimeout { - pub(crate) fn not_zero(&self) -> Option { + /// Returns the duration of the timeout if the timeout must happen, but avoid instant timeouts + /// + /// If the timeout must happen but is zero, returns 1 second + pub fn not_zero(&self) -> Option { if self.after.is_not_happening() { None } else if self.after.is_zero() {