1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*******************************************************************************
*
* Copyright (c) 2025 - 2026 Haixing Hu.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0.
*
******************************************************************************/
//! # Wait Timeout Result
//!
//! Provides the result returned by predicate-based timed monitor waits.
//!
/// Result of waiting for a predicate with an overall timeout.
///
/// This type is returned by
/// [`Monitor::wait_timeout_while`](super::Monitor::wait_timeout_while) and
/// [`Monitor::wait_timeout_until`](super::Monitor::wait_timeout_until). It is
/// more explicit than `Option<R>`: a ready predicate produces [`Self::Ready`],
/// while an expired timeout produces [`Self::TimedOut`].
///
/// # Type Parameters
///
/// * `R` - The value produced after the protected state satisfies the
/// predicate.
///
/// # Example
///
/// ```rust
/// use std::time::Duration;
///
/// use qubit_lock::lock::{Monitor, WaitTimeoutResult};
///
/// let monitor = Monitor::new(true);
/// let result = monitor.wait_timeout_until(
/// Duration::from_secs(1),
/// |ready| *ready,
/// |ready| {
/// *ready = false;
/// "ready"
/// },
/// );
///
/// assert_eq!(result, WaitTimeoutResult::Ready("ready"));
/// ```