Skip to main content

a3s_effect/
exit.rs

1/// How a program stops.
2///
3/// `Fail` is an expected error and stays in the type. `Die` is a defect.
4/// `Interrupt` is cancellation from a parent scope. Retries and `catch_fail`
5/// see only `Fail`.
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum Exit<E> {
8    Fail(E),
9    Die(String),
10    Interrupt,
11}
12
13impl<E> Exit<E> {
14    pub fn is_interrupt(&self) -> bool {
15        matches!(self, Self::Interrupt)
16    }
17}
18
19impl From<crate::error::ActorError> for Exit<crate::error::ActorError> {
20    fn from(error: crate::error::ActorError) -> Self {
21        Self::Fail(error)
22    }
23}