tuwunel_core/utils/future/ready_bool_ext.rs
1#![expect(clippy::wrong_self_convention)]
2
3use super::ReadyEqExt;
4
5/// Tests the Boolean output of a future without awaiting it early.
6///
7/// The helpers attach equality comparisons to the future. Each returned future
8/// resolves to the requested truth-state test.
9pub trait ReadyBoolExt
10where
11 Self: Future<Output = bool> + ReadyEqExt<bool> + Send,
12{
13 /// Reports whether the future resolves to false.
14 ///
15 /// The receiver is consumed, then its output is compared with `false` after
16 /// completion.
17 #[inline]
18 fn is_false(self) -> impl Future<Output = bool> + Send { self.eq(&false) }
19
20 /// Reports whether the future resolves to true.
21 ///
22 /// The receiver is consumed, then its output is compared with `true` after
23 /// completion.
24 #[inline]
25 fn is_true(self) -> impl Future<Output = bool> + Send { self.eq(&true) }
26}
27
28impl<Fut> ReadyBoolExt for Fut where Fut: Future<Output = bool> + Send {}