Skip to main content

eggfetch_core/
timeout.rs

1//! Phase-aware timeout configuration.
2//!
3//! Timeouts are applied per-phase during the request lifecycle. Each phase
4//! measures a specific segment of the request:
5//!
6//! - **Pool**: time waiting for a connection slot from the pool.
7//! - **Connect**: time to establish the TCP connection and TLS handshake
8//!   (including DNS resolution).
9//! - **`ProxyConnect`**: TCP connection to the proxy server. Only applies
10//!   when a proxy is configured.
11//! - **`ProxyTls`**: TLS handshake over a CONNECT tunnel to the proxy.
12//!   Only applies to HTTPS targets routed through an HTTP proxy.
13//! - **Write**: time for the request body producer to yield each chunk.
14//!   Only applies to streamed request bodies; buffered bodies complete
15//!   synchronously.
16//! - **Read**: time to wait for response headers and each response body
17//!   chunk. The deadline resets on every chunk arrival. The timer starts
18//!   when body consumption begins, not when response headers arrive.
19//! - **Total**: absolute wall-clock deadline across the entire request
20//!   lifecycle, from logical request start through response-body EOF (or
21//!   terminal body error), including pool acquisition, transport setup,
22//!   response headers, body chunks, decompression, and trailers. It never
23//!   resets on chunk arrival, decoding selection, or first body poll. A body
24//!   that is first polled after the deadline reports `Total` without
25//!   accepting a ready inner chunk.
26//!
27//! # Proxy timeout phases
28//!
29//! When a request is routed through a proxy, the connect phase splits
30//! into two sub-phases:
31//!
32//! 1. `ProxyConnect` — the TCP connection from the client to the proxy.
33//! 2. `ProxyTls` — the TLS handshake over the CONNECT tunnel (HTTPS
34//!    targets only).
35//!
36//! After the tunnel is established, regular `Connect`, `Send`, and
37//! `Receive` semantics apply to the destination.
38//!
39//! # Enforcement
40//!
41//! - **Pool** and **Total** are enforced with `tokio::time::timeout`.
42//! - **Read** is enforced by a per-chunk wrapper stream that fires
43//!   `Error::Timeout { phase: Read }` if no chunk arrives within the
44//!   configured duration. The deadline starts on first body poll and resets
45//!   on every chunk.
46//! - **Total** is enforced in two stages: `tokio::time::timeout` bounds the
47//!   transport future up to response headers, and a crate-private absolute
48//!   response-body deadline (`ResponseDeadline`) bounds body streaming
49//!   through EOF/trailers. The absolute instant never resets; an
50//!   already-expired deadline wins before polling the inner body, and when
51//!   both read and total are observably expired at the same poll boundary
52//!   `Total` is preferred as the outer lifecycle cap.
53//! - **Write** is enforced by a per-chunk wrapper stream that fires
54//!   `Error::Timeout { phase: Write }` if the producer does not yield
55//!   the next chunk within the configured duration. The deadline resets
56//!   on every chunk.
57//! - **Connect** is enforced by wrapping the underlying connector with a
58//!   timeout that bounds the entire connection-establishment phase (DNS
59//!   resolution, TCP connect, and TLS handshake). Fires
60//!   `Error::Timeout { phase: Connect }` if the connection is not
61//!   established within the configured duration.
62//!
63//! When a scalar timeout is provided (e.g. `Timeout::from_secs(5)`), it
64//! applies to pool, connect, write, and read phases. The total timeout is
65//! not set by scalar constructors unless explicitly specified.
66//!
67//! Request-level timeout overrides client-level timeout on a per-field
68//! basis: only the fields present in the request-level timeout replace
69//! the corresponding client-level fields.
70
71use std::time::Duration;
72
73/// Identifies the phase of a request that timed out.
74#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
75pub enum TimeoutPhase {
76    /// Waiting for a connection slot from the pool.
77    Pool,
78    /// Establishing TCP connection and TLS handshake.
79    Connect,
80    /// TCP connection to the proxy server.
81    ProxyConnect,
82    /// TLS handshake over a CONNECT tunnel to the proxy.
83    ProxyTls,
84    /// Sending request headers and body.
85    Write,
86    /// Waiting for response headers or a response body chunk.
87    Read,
88    /// The overall wall-clock deadline was exceeded.
89    Total,
90}
91
92impl std::fmt::Display for TimeoutPhase {
93    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
94        match self {
95            Self::Pool => write!(f, "pool"),
96            Self::Connect => write!(f, "connect"),
97            Self::ProxyConnect => write!(f, "proxy connect"),
98            Self::ProxyTls => write!(f, "proxy TLS"),
99            Self::Read => write!(f, "read"),
100            Self::Write => write!(f, "write"),
101            Self::Total => write!(f, "total"),
102        }
103    }
104}
105
106/// Phase-aware timeout configuration for a request.
107///
108/// Each field is optional. When `None`, the corresponding phase has no
109/// timeout. When a field is `Some(duration)`, the phase will fail with
110/// [`crate::Error::Timeout`] if it exceeds the given duration.
111///
112/// # Enforcement
113///
114/// - `pool`: enforced via `tokio::time::timeout` around the pool acquire.
115/// - `read`: enforced per chunk by a wrapper stream that fires
116///   `Error::Timeout { phase: Read }` when no data arrives within the
117///   configured duration. Resets on every chunk arrival.
118/// - `write`: enforced per chunk by a wrapper stream that fires
119///   `Error::Timeout { phase: Write }` when the request body producer
120///   does not yield a chunk within the configured duration. Resets on
121///   every chunk delivery. Only applies to streamed request bodies;
122///   buffered bodies complete synchronously.
123/// - `total`: absolute wall-clock deadline from logical request start
124///   through response-body EOF/trailers. Enforced around the transport
125///   future and retained on the response body; never restarted per chunk,
126///   decode selection, redirect hop, retry attempt, or first body poll.
127/// - `connect`: enforced by wrapping the underlying connector with a
128///   timeout that bounds DNS resolution, TCP connect, and TLS handshake.
129///   Fires `Error::Timeout { phase: Connect }` if the connection is not
130///   established within the configured duration.
131///
132/// # Default
133///
134/// The default `Timeout` has all phases disabled (all `None`).
135///
136/// # Examples
137///
138/// ```
139/// use std::time::Duration;
140/// use eggfetch_core::Timeout;
141///
142/// // All phases get 5 seconds.
143/// let t = Timeout::from_secs(5);
144///
145/// // Only read and total are configured.
146/// let t = Timeout {
147///     read: Some(Duration::from_secs(30)),
148///     total: Some(Duration::from_secs(60)),
149///     ..Timeout::default()
150/// };
151/// ```
152#[derive(Debug, Default, Clone, Copy)]
153pub struct Timeout {
154    /// Time allowed to wait for a connection slot from the pool.
155    pub pool: Option<Duration>,
156    /// Time allowed to establish TCP connection and TLS handshake.
157    /// Includes DNS resolution when performed as part of connect.
158    /// Enforced by wrapping the underlying connector with a deadline.
159    pub connect: Option<Duration>,
160    /// Time allowed for the request body producer to yield each frame.
161    /// Applies to high-level streamed request bodies and the native
162    /// `http_body::Body` execution surface.
163    pub write: Option<Duration>,
164    /// Time allowed between response body chunks. Resets on every chunk.
165    pub read: Option<Duration>,
166    /// Optional wall-clock cap across the entire request lifecycle.
167    pub total: Option<Duration>,
168}
169
170impl Timeout {
171    /// Create a timeout with all phases disabled.
172    ///
173    /// This is the same as `Timeout::default()`.
174    #[must_use]
175    pub fn disabled() -> Self {
176        Self::default()
177    }
178
179    /// Create a timeout where pool, connect, write, and read each get the
180    /// given duration.
181    ///
182    /// The total timeout is not set. Use [`Timeout::builder`] or the
183    /// struct literal syntax to set it explicitly.
184    ///
185    /// # Examples
186    ///
187    /// ```
188    /// use eggfetch_core::Timeout;
189    ///
190    /// let t = Timeout::from_secs(5);
191    /// assert_eq!(t.pool, Some(std::time::Duration::from_secs(5)));
192    /// assert_eq!(t.connect, Some(std::time::Duration::from_secs(5)));
193    /// assert_eq!(t.write, Some(std::time::Duration::from_secs(5)));
194    /// assert_eq!(t.read, Some(std::time::Duration::from_secs(5)));
195    /// assert!(t.total.is_none());
196    /// ```
197    #[must_use]
198    pub fn from_secs(secs: u64) -> Self {
199        let d = Duration::from_secs(secs);
200        Self {
201            pool: Some(d),
202            connect: Some(d),
203            write: Some(d),
204            read: Some(d),
205            total: None,
206        }
207    }
208
209    /// Create an HTTPX-compatible timeout configuration.
210    ///
211    /// HTTPX 0.28.1 uses 5 seconds for each operational phase. It does not
212    /// define a request-wide wall-clock timeout, so `total` remains unset.
213    /// Set `total` explicitly when an EggFetch-native outer deadline is
214    /// desired.
215    ///
216    /// # Examples
217    ///
218    /// ```
219    /// use std::time::Duration;
220    /// use eggfetch_core::Timeout;
221    ///
222    /// let t = Timeout::compat();
223    /// assert_eq!(t.pool, Some(Duration::from_secs(5)));
224    /// assert_eq!(t.connect, Some(Duration::from_secs(5)));
225    /// assert_eq!(t.write, Some(Duration::from_secs(5)));
226    /// assert_eq!(t.read, Some(Duration::from_secs(5)));
227    /// assert!(t.total.is_none());
228    /// ```
229    #[must_use]
230    pub fn compat() -> Self {
231        let d = Duration::from_secs(5);
232        Self {
233            pool: Some(d),
234            connect: Some(d),
235            write: Some(d),
236            read: Some(d),
237            total: None,
238        }
239    }
240
241    /// Create eggfetch-native timeout defaults.
242    ///
243    /// Uses 30 seconds for pool, connect, write, and read phases with
244    /// no total timeout. This is appropriate for general-purpose use
245    /// where the caller controls overall deadlines.
246    ///
247    /// # Examples
248    ///
249    /// ```
250    /// use std::time::Duration;
251    /// use eggfetch_core::Timeout;
252    ///
253    /// let t = Timeout::native();
254    /// assert_eq!(t.pool, Some(Duration::from_secs(30)));
255    /// assert_eq!(t.connect, Some(Duration::from_secs(30)));
256    /// assert_eq!(t.write, Some(Duration::from_secs(30)));
257    /// assert_eq!(t.read, Some(Duration::from_secs(30)));
258    /// assert!(t.total.is_none());
259    /// ```
260    #[must_use]
261    pub fn native() -> Self {
262        let d = Duration::from_secs(30);
263        Self {
264            pool: Some(d),
265            connect: Some(d),
266            write: Some(d),
267            read: Some(d),
268            total: None,
269        }
270    }
271
272    /// Create a [`TimeoutBuilder`] for configuring individual phases.
273    #[must_use]
274    pub fn builder() -> TimeoutBuilder {
275        TimeoutBuilder {
276            pool: None,
277            connect: None,
278            write: None,
279            read: None,
280            total: None,
281        }
282    }
283
284    /// Merge request-level overrides into client-level defaults.
285    ///
286    /// For each phase, if the request-level value is `Some`, it replaces
287    /// the client-level value. If `None`, the client-level value is kept.
288    #[must_use]
289    pub(crate) fn merge(self, override_timeout: Option<Self>) -> Self {
290        match override_timeout {
291            Some(req) => Self {
292                pool: req.pool.or(self.pool),
293                connect: req.connect.or(self.connect),
294                write: req.write.or(self.write),
295                read: req.read.or(self.read),
296                total: req.total.or(self.total),
297            },
298            None => self,
299        }
300    }
301
302    /// Returns `true` if any phase has a timeout set.
303    #[must_use]
304    pub fn has_any(&self) -> bool {
305        self.pool.is_some()
306            || self.connect.is_some()
307            || self.write.is_some()
308            || self.read.is_some()
309            || self.total.is_some()
310    }
311}
312
313/// Crate-private absolute response-body deadline for the native `total`
314/// timeout.
315///
316/// The instant is computed once during request preparation
317/// (`started + total`) and never changes afterwards: it does not start on
318/// first body poll, reset on chunk/frame arrival, restart on decode
319/// selection, or restart across redirect/retry hops. The owning stream
320/// retains only this `std::time::Instant` plus the hop total used for
321/// `Error::Timeout` elapsed reporting; Tokio timers are created lazily on
322/// first body poll in the consuming runtime so a response handed to another
323/// runtime (e.g. the synchronous Python adapter) never carries a
324/// runtime-bound sleep across the boundary.
325///
326/// Dropping a response before EOF remains ordinary cancellation and never
327/// manufactures a timeout; the deadline only surfaces as
328/// `TimeoutPhase::Total` when the body is polled at or after expiry.
329#[derive(Debug, Clone, Copy)]
330pub(crate) struct ResponseDeadline {
331    deadline: std::time::Instant,
332    total: Duration,
333}
334
335impl ResponseDeadline {
336    /// Capture the absolute deadline with the hop total used for elapsed
337    /// reporting.
338    #[must_use]
339    pub(crate) fn new(deadline: std::time::Instant, total: Duration) -> Self {
340        Self { deadline, total }
341    }
342
343    /// The absolute instant the logical request expires.
344    #[must_use]
345    pub(crate) fn deadline(&self) -> std::time::Instant {
346        self.deadline
347    }
348
349    /// Returns `true` when the wall-clock deadline has passed.
350    #[must_use]
351    pub(crate) fn is_expired(&self) -> bool {
352        std::time::Instant::now() >= self.deadline
353    }
354
355    /// Elapsed time for `Error::Timeout` reporting: time since the hop
356    /// started (`deadline - total`), matching the transport-stage total
357    /// convention of reporting hop-local elapsed rather than a bare
358    /// zero-duration expiry.
359    #[must_use]
360    pub(crate) fn elapsed(&self) -> Duration {
361        let started = self
362            .deadline
363            .checked_sub(self.total)
364            .unwrap_or(self.deadline);
365        started.elapsed()
366    }
367}
368
369/// Builder for constructing a [`Timeout`] with individual phase durations.
370///
371/// Created by [`Timeout::builder()`].
372#[derive(Debug, Clone)]
373pub struct TimeoutBuilder {
374    pool: Option<Duration>,
375    connect: Option<Duration>,
376    write: Option<Duration>,
377    read: Option<Duration>,
378    total: Option<Duration>,
379}
380
381impl TimeoutBuilder {
382    /// Set the pool acquisition timeout.
383    #[must_use]
384    pub fn pool(mut self, timeout: Duration) -> Self {
385        self.pool = Some(timeout);
386        self
387    }
388
389    /// Set the connect timeout.
390    #[must_use]
391    pub fn connect(mut self, timeout: Duration) -> Self {
392        self.connect = Some(timeout);
393        self
394    }
395
396    /// Set the write timeout.
397    #[must_use]
398    pub fn write(mut self, timeout: Duration) -> Self {
399        self.write = Some(timeout);
400        self
401    }
402
403    /// Set the read timeout.
404    #[must_use]
405    pub fn read(mut self, timeout: Duration) -> Self {
406        self.read = Some(timeout);
407        self
408    }
409
410    /// Set the total request timeout.
411    #[must_use]
412    pub fn total(mut self, timeout: Duration) -> Self {
413        self.total = Some(timeout);
414        self
415    }
416
417    /// Build the [`Timeout`].
418    #[must_use]
419    pub fn build(self) -> Timeout {
420        Timeout {
421            pool: self.pool,
422            connect: self.connect,
423            write: self.write,
424            read: self.read,
425            total: self.total,
426        }
427    }
428}
429
430#[cfg(test)]
431mod tests {
432    use super::*;
433    use proptest::prelude::*;
434
435    #[test]
436    fn timeout_default_all_none() {
437        let t = Timeout::default();
438        assert!(t.pool.is_none());
439        assert!(t.connect.is_none());
440        assert!(t.write.is_none());
441        assert!(t.read.is_none());
442        assert!(t.total.is_none());
443    }
444
445    #[test]
446    fn timeout_disabled_same_as_default() {
447        let t = Timeout::disabled();
448        assert!(!t.has_any());
449    }
450
451    #[test]
452    fn timeout_from_secs_sets_phases() {
453        let t = Timeout::from_secs(10);
454        assert_eq!(t.pool, Some(Duration::from_secs(10)));
455        assert_eq!(t.connect, Some(Duration::from_secs(10)));
456        assert_eq!(t.write, Some(Duration::from_secs(10)));
457        assert_eq!(t.read, Some(Duration::from_secs(10)));
458        assert!(t.total.is_none());
459    }
460
461    #[test]
462    fn timeout_builder_sets_all() {
463        let t = Timeout::builder()
464            .pool(Duration::from_secs(1))
465            .connect(Duration::from_secs(2))
466            .write(Duration::from_secs(3))
467            .read(Duration::from_secs(4))
468            .total(Duration::from_secs(5))
469            .build();
470        assert_eq!(t.pool, Some(Duration::from_secs(1)));
471        assert_eq!(t.connect, Some(Duration::from_secs(2)));
472        assert_eq!(t.write, Some(Duration::from_secs(3)));
473        assert_eq!(t.read, Some(Duration::from_secs(4)));
474        assert_eq!(t.total, Some(Duration::from_secs(5)));
475    }
476
477    #[test]
478    fn timeout_merge_request_overrides_client() {
479        let client = Timeout::from_secs(10);
480        let request = Timeout {
481            read: Some(Duration::from_secs(30)),
482            ..Timeout::default()
483        };
484        let merged = client.merge(Some(request));
485        assert_eq!(merged.pool, Some(Duration::from_secs(10)));
486        assert_eq!(merged.connect, Some(Duration::from_secs(10)));
487        assert_eq!(merged.write, Some(Duration::from_secs(10)));
488        assert_eq!(merged.read, Some(Duration::from_secs(30)));
489        assert!(merged.total.is_none());
490    }
491
492    #[test]
493    fn timeout_merge_no_override() {
494        let client = Timeout::from_secs(5);
495        let merged = client.merge(None);
496        assert_eq!(merged.pool, Some(Duration::from_secs(5)));
497        assert_eq!(merged.connect, Some(Duration::from_secs(5)));
498    }
499
500    #[test]
501    fn timeout_compat_sets_operational_phases_without_total() {
502        let t = Timeout::compat();
503        let d = Duration::from_secs(5);
504        assert_eq!(t.pool, Some(d));
505        assert_eq!(t.connect, Some(d));
506        assert_eq!(t.write, Some(d));
507        assert_eq!(t.read, Some(d));
508        assert!(t.total.is_none());
509    }
510
511    #[test]
512    fn timeout_native_sets_phases_without_total() {
513        let t = Timeout::native();
514        let d = Duration::from_secs(30);
515        assert_eq!(t.pool, Some(d));
516        assert_eq!(t.connect, Some(d));
517        assert_eq!(t.write, Some(d));
518        assert_eq!(t.read, Some(d));
519        assert!(t.total.is_none());
520    }
521
522    #[test]
523    fn timeout_has_any() {
524        assert!(!Timeout::default().has_any());
525        assert!(Timeout::from_secs(1).has_any());
526        assert!(Timeout {
527            total: Some(Duration::from_secs(1)),
528            ..Timeout::default()
529        }
530        .has_any());
531    }
532
533    #[test]
534    fn timeout_phase_display() {
535        assert_eq!(TimeoutPhase::Pool.to_string(), "pool");
536        assert_eq!(TimeoutPhase::Connect.to_string(), "connect");
537        assert_eq!(TimeoutPhase::ProxyConnect.to_string(), "proxy connect");
538        assert_eq!(TimeoutPhase::ProxyTls.to_string(), "proxy TLS");
539        assert_eq!(TimeoutPhase::Write.to_string(), "write");
540        assert_eq!(TimeoutPhase::Read.to_string(), "read");
541        assert_eq!(TimeoutPhase::Total.to_string(), "total");
542    }
543
544    #[test]
545    fn timeout_merge_empty_override_preserves_client() {
546        let client = Timeout {
547            pool: Some(Duration::from_secs(1)),
548            connect: Some(Duration::from_secs(2)),
549            write: Some(Duration::from_secs(3)),
550            read: Some(Duration::from_secs(4)),
551            total: Some(Duration::from_secs(5)),
552        };
553        let merged = client.merge(Some(Timeout::default()));
554        assert_eq!(merged.pool, Some(Duration::from_secs(1)));
555        assert_eq!(merged.connect, Some(Duration::from_secs(2)));
556        assert_eq!(merged.write, Some(Duration::from_secs(3)));
557        assert_eq!(merged.read, Some(Duration::from_secs(4)));
558        assert_eq!(merged.total, Some(Duration::from_secs(5)));
559    }
560
561    #[test]
562    fn timeout_builder_matches_from_secs_for_phases() {
563        let scalar = Timeout::from_secs(5);
564        let builder = Timeout::builder()
565            .pool(Duration::from_secs(5))
566            .connect(Duration::from_secs(5))
567            .write(Duration::from_secs(5))
568            .read(Duration::from_secs(5))
569            .build();
570        assert_eq!(scalar.pool, builder.pool);
571        assert_eq!(scalar.connect, builder.connect);
572        assert_eq!(scalar.write, builder.write);
573        assert_eq!(scalar.read, builder.read);
574        assert_eq!(scalar.total, builder.total);
575    }
576
577    #[test]
578    fn timeout_merge_request_overrides_total() {
579        let client = Timeout::from_secs(10);
580        let request = Timeout {
581            total: Some(Duration::from_secs(60)),
582            ..Timeout::default()
583        };
584        let merged = client.merge(Some(request));
585        assert_eq!(merged.total, Some(Duration::from_secs(60)));
586        assert_eq!(merged.pool, Some(Duration::from_secs(10)));
587    }
588
589    #[test]
590    fn zero_duration_timeout_is_valid() {
591        // Zero is a valid Duration in Rust (unsigned). It produces an immediate
592        // timeout when used with tokio::time::timeout. This is documented
593        // behavior, not an error.
594        let t = Timeout::from_secs(0);
595        assert_eq!(t.pool, Some(Duration::ZERO));
596        assert_eq!(t.connect, Some(Duration::ZERO));
597        assert_eq!(t.write, Some(Duration::ZERO));
598        assert_eq!(t.read, Some(Duration::ZERO));
599        assert_eq!(t.total, None);
600    }
601
602    proptest::proptest! {
603        #[test]
604        fn from_secs_sets_correct_phases(secs in 0u64..86400) {
605            let t = Timeout::from_secs(secs);
606            let d = Duration::from_secs(secs);
607            prop_assert_eq!(t.pool, Some(d));
608            prop_assert_eq!(t.connect, Some(d));
609            prop_assert_eq!(t.write, Some(d));
610            prop_assert_eq!(t.read, Some(d));
611            prop_assert!(t.total.is_none());
612        }
613
614        #[test]
615        fn disabled_has_no_phases(_ in 0u64..100) {
616            let t = Timeout::disabled();
617            prop_assert!(!t.has_any());
618            prop_assert!(t.pool.is_none());
619            prop_assert!(t.connect.is_none());
620            prop_assert!(t.write.is_none());
621            prop_assert!(t.read.is_none());
622            prop_assert!(t.total.is_none());
623        }
624
625        #[test]
626        fn has_any_consistent_with_fields(
627            pool in proptest::option::of(0u64..3600),
628            connect in proptest::option::of(0u64..3600),
629            write in proptest::option::of(0u64..3600),
630            read in proptest::option::of(0u64..3600),
631            total in proptest::option::of(0u64..3600),
632        ) {
633            let t = Timeout {
634                pool: pool.map(Duration::from_secs),
635                connect: connect.map(Duration::from_secs),
636                write: write.map(Duration::from_secs),
637                read: read.map(Duration::from_secs),
638                total: total.map(Duration::from_secs),
639            };
640            let expected = t.pool.is_some() || t.connect.is_some() || t.write.is_some() || t.read.is_some() || t.total.is_some();
641            prop_assert_eq!(t.has_any(), expected);
642        }
643
644        #[test]
645        fn builder_round_trip(
646            pool in 0u64..3600,
647            connect in 0u64..3600,
648            write in 0u64..3600,
649            read in 0u64..3600,
650            total in 0u64..3600,
651        ) {
652            let t = Timeout::builder()
653                .pool(Duration::from_secs(pool))
654                .connect(Duration::from_secs(connect))
655                .write(Duration::from_secs(write))
656                .read(Duration::from_secs(read))
657                .total(Duration::from_secs(total))
658                .build();
659            prop_assert_eq!(t.pool, Some(Duration::from_secs(pool)));
660            prop_assert_eq!(t.connect, Some(Duration::from_secs(connect)));
661            prop_assert_eq!(t.write, Some(Duration::from_secs(write)));
662            prop_assert_eq!(t.read, Some(Duration::from_secs(read)));
663            prop_assert_eq!(t.total, Some(Duration::from_secs(total)));
664        }
665    }
666}