Skip to main content

guard_core_engine/redos/
timeout.rs

1//! The `BuilderTimeout` error: the port of the reference's `TimeoutError`
2//! raised by every deadline and budget guard in the probe builders.
3//!
4//! The message text is the reference exception text; the arbiter surfaces
5//! it verbatim in the verdict reason.
6
7/// The reference `TimeoutError` analog for probe construction.
8#[derive(Debug, Clone, PartialEq, Eq)]
9pub struct BuilderTimeout(pub String);
10
11impl std::fmt::Display for BuilderTimeout {
12    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13        write!(f, "{}", self.0)
14    }
15}
16
17impl std::error::Error for BuilderTimeout {}
18
19#[cfg(test)]
20mod tests {
21    use super::*;
22
23    #[test]
24    fn display_produces_the_reference_exception_text() {
25        let error = BuilderTimeout("boom".into());
26        assert_eq!(error.to_string(), "boom");
27    }
28}