Skip to main content

ExitReason

Enum ExitReason 

Source
pub enum ExitReason {
    Normal,
    Shutdown,
    ShutdownReason(String),
    Killed,
    Error(String),
}
Expand description

The reason a process exited.

Exit reasons determine how linked processes and supervisors respond to process termination.

§Normal vs Abnormal Exits

§Examples

use starlang_core::ExitReason;

let reason = ExitReason::Normal;
assert!(reason.is_normal());

let reason = ExitReason::Error("connection lost".to_string());
assert!(!reason.is_normal());

Variants§

§

Normal

Process completed successfully.

This is the standard exit reason when a process finishes its work without errors.

§

Shutdown

Process was asked to shut down.

Used when a supervisor or other controller requests graceful termination.

§

ShutdownReason(String)

Process was asked to shut down with a specific reason.

Similar to Shutdown but includes additional context.

§

Killed

Process was forcefully terminated.

Used with Process::exit(pid, ExitReason::Killed) for unconditional termination that cannot be trapped.

§

Error(String)

Process terminated due to an error.

This is an abnormal exit that will trigger supervisor restarts and propagate through links.

Implementations§

Source§

impl ExitReason

Source

pub fn is_normal(&self) -> bool

Returns true if this is a normal exit reason.

Normal exits include Normal, Shutdown, and ShutdownReason. These do not trigger supervisor restarts for Transient children.

§Examples
use starlang_core::ExitReason;

assert!(ExitReason::Normal.is_normal());
assert!(ExitReason::Shutdown.is_normal());
assert!(ExitReason::ShutdownReason("done".into()).is_normal());
assert!(!ExitReason::Killed.is_normal());
assert!(!ExitReason::Error("oops".into()).is_normal());
Source

pub fn is_abnormal(&self) -> bool

Returns true if this is an abnormal exit reason.

Abnormal exits include Killed and Error. These trigger supervisor restarts and propagate through links to non-trapping processes.

Source

pub fn is_killed(&self) -> bool

Returns true if this is the Killed variant.

The Killed reason is special: it cannot be trapped and always terminates the target process.

Source

pub fn error(msg: impl Display) -> ExitReason

Creates an error exit reason from any displayable type.

§Examples
use starlang_core::ExitReason;

let reason = ExitReason::error("something went wrong");
assert_eq!(reason, ExitReason::Error("something went wrong".to_string()));
Source

pub fn shutdown(msg: impl Display) -> ExitReason

Creates a shutdown exit reason with a message.

§Examples
use starlang_core::ExitReason;

let reason = ExitReason::shutdown("maintenance");
assert!(reason.is_normal());

Trait Implementations§

Source§

impl Clone for ExitReason

Source§

fn clone(&self) -> ExitReason

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExitReason

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for ExitReason

Source§

fn default() -> ExitReason

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ExitReason

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<ExitReason, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ExitReason

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for ExitReason

Source§

impl From<&str> for ExitReason

Source§

fn from(s: &str) -> ExitReason

Converts to this type from the input type.
Source§

impl From<String> for ExitReason

Source§

fn from(s: String) -> ExitReason

Converts to this type from the input type.
Source§

impl PartialEq for ExitReason

Source§

fn eq(&self, other: &ExitReason) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ExitReason

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ExitReason

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Message for T
where T: Term,

Source§

impl<T> Term for T
where T: Serialize + DeserializeOwned + Send + 'static,

Source§

fn encode(&self) -> Vec<u8>

Encodes this term into bytes. Read more
Source§

fn decode(bytes: &[u8]) -> Result<T, DecodeError>

Decodes a term from bytes. Read more
Source§

fn try_encode(&self) -> Option<Vec<u8>>

Encodes this term, returning None on failure instead of panicking.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.