pub enum ExitReason {
Normal,
Killed,
Panic(String),
Shutdown,
Custom(String),
}Expand description
Reason for actor termination.
Exit reasons indicate why an actor stopped. They are used to determine whether a supervisor should restart a failed actor.
§Examples
use joerl::ExitReason;
let normal = ExitReason::Normal;
assert!(normal.is_normal());
assert!(normal.is_trappable());
let killed = ExitReason::Killed;
assert!(!killed.is_normal());
assert!(!killed.is_trappable()); // Cannot be trapped
let panic = ExitReason::Panic("something went wrong".to_string());
assert!(!panic.is_normal());
assert_eq!(panic.to_string(), "panic: something went wrong");Variants§
Normal
Normal termination.
Killed
Actor was killed explicitly.
Panic(String)
Actor panicked with an error message.
Shutdown
Actor terminated due to supervisor shutdown.
Custom(String)
Custom exit reason.
Implementations§
Source§impl ExitReason
impl ExitReason
Sourcepub fn is_normal(&self) -> bool
pub fn is_normal(&self) -> bool
Returns true if this is a normal exit.
Normal exits typically don’t trigger restarts in supervisors.
§Examples
use joerl::ExitReason;
assert!(ExitReason::Normal.is_normal());
assert!(!ExitReason::Killed.is_normal());
assert!(!ExitReason::Panic("error".into()).is_normal());Sourcepub fn is_trappable(&self) -> bool
pub fn is_trappable(&self) -> bool
Returns true if this exit reason can be trapped.
Actors with trap_exit(true) can handle trappable exit signals
without terminating. The Killed reason cannot be trapped.
§Examples
use joerl::ExitReason;
assert!(ExitReason::Normal.is_trappable());
assert!(ExitReason::Panic("error".into()).is_trappable());
assert!(!ExitReason::Killed.is_trappable()); // Cannot be trappedTrait Implementations§
Source§impl Clone for ExitReason
impl Clone for ExitReason
Source§fn clone(&self) -> ExitReason
fn clone(&self) -> ExitReason
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ExitReason
impl Debug for ExitReason
Source§impl Display for ExitReason
impl Display for ExitReason
Source§impl PartialEq for ExitReason
impl PartialEq for ExitReason
impl Eq for ExitReason
impl StructuralPartialEq for ExitReason
Auto Trait Implementations§
impl Freeze for ExitReason
impl RefUnwindSafe for ExitReason
impl Send for ExitReason
impl Sync for ExitReason
impl Unpin for ExitReason
impl UnwindSafe for ExitReason
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more