Skip to main content

tuwunel_core/utils/result/
not_found.rs

1use super::Result;
2use crate::Error;
3
4/// Classifies results that contain the crate's not-found error family.
5///
6/// Successful results and unrelated errors are not classified as missing.
7/// Classification delegates to `Error::is_not_found`.
8pub trait NotFound<T> {
9	/// Reports whether the result contains a not-found error.
10	///
11	/// An `Ok` value always returns false. Other error variants also return
12	/// false without changing the result.
13	#[must_use]
14	fn is_not_found(&self) -> bool;
15}
16
17impl<T> NotFound<T> for Result<T, Error> {
18	#[inline]
19	fn is_not_found(&self) -> bool { self.as_ref().is_err_and(Error::is_not_found) }
20}