use std::fmt;
use crate::error::PanicError;
#[derive(Clone)]
pub enum ActorStopReason {
Normal,
Killed,
Panicked(PanicError),
LinkDied {
id: u64,
reason: Box<ActorStopReason>,
},
}
impl fmt::Debug for ActorStopReason {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ActorStopReason::Normal => write!(f, "Normal"),
ActorStopReason::Killed => write!(f, "Killed"),
ActorStopReason::Panicked(_) => write!(f, "Panicked"),
ActorStopReason::LinkDied { id, reason } => f
.debug_struct("LinkDied")
.field("id", id)
.field("reason", &reason)
.finish(),
}
}
}
impl fmt::Display for ActorStopReason {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ActorStopReason::Normal => write!(f, "actor stopped normally"),
ActorStopReason::Killed => write!(f, "actor was killed"),
ActorStopReason::Panicked(err) => err.fmt(f),
ActorStopReason::LinkDied { id, reason: _ } => {
write!(f, "link {id} died")
}
}
}
}