async_backplane/
crash.rs

1use crate::{DeviceID, Fault, panic::Unwind};
2
3/// Something went wrong with a Device.
4#[derive(Debug)]
5pub enum Crash<Error> {
6    /// We were asked to shut down.
7    PowerOff(DeviceID),
8    /// The Future we were executing panicked.
9    Panic(Unwind),
10    /// The Future we were executing returned an Err.
11    Error(Error),
12    /// A device we depended upon faulted.
13    Cascade(DeviceID, Fault),
14}
15
16impl<Error> Crash<Error> {
17
18    /// Did the future unwind panic?
19    pub fn is_panic(&self) -> bool { matches!(self, Crash::Panic(_)) }
20
21    /// Did the future return Err?
22    pub fn is_error(&self) -> bool { matches!(self, Crash::Error(_)) }
23
24    /// Did a Device we depend on fault?
25    pub fn is_cascade(&self) -> bool { matches!(self, Crash::Cascade(_, _)) }
26
27}