Skip to main content

nodedb_types/fail_point/
scope.rs

1// SPDX-License-Identifier: Apache-2.0
2
3//! The node scope of a fail point.
4
5use std::fmt;
6
7/// The nodes an armed fail point applies to, and the node a point is
8/// evaluated on.
9///
10/// Compiled without the `failpoints` feature too, so a call site can name
11/// its scope in every build.
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
13pub enum FailScope {
14    /// Every node. Code with no node identity evaluates its points here.
15    Any,
16    /// The node with this id.
17    Node(u64),
18}
19
20impl fmt::Display for FailScope {
21    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22        match self {
23            Self::Any => f.write_str("any node"),
24            Self::Node(id) => write!(f, "node {id}"),
25        }
26    }
27}