ExitCode

Enum ExitCode 

Source
#[repr(i32)]
pub enum ExitCode {
Show 19 variants Success = 0, Error = 1, UsageError = 64, DataError = 65, NoInput = 66, NoUser = 67, NoHost = 68, Unavailable = 69, Software = 70, OsError = 71, OsFile = 72, CantCreate = 73, IoError = 74, TempFail = 75, Protocol = 76, NoPerm = 77, Config = 78, Interrupted = 130, Terminated = 143,
}
Expand description

Exit codes following Unix conventions (BSD sysexits.h)

Variants§

§

Success = 0

Successful termination (0)

§

Error = 1

General error (1)

§

UsageError = 64

Command line usage error (64)

  • Invalid arguments
  • Missing required arguments
  • Unknown flags
§

DataError = 65

Data format error (65)

  • Invalid input data
  • Malformed configuration
  • Parse errors
§

NoInput = 66

Cannot open input (66)

  • File not found
  • Cannot read file
  • Permission denied on input
§

NoUser = 67

User does not exist (67)

  • Unknown user specified
  • Invalid user context
§

NoHost = 68

Host name unknown (68)

  • Unknown host
  • Cannot resolve hostname
§

Unavailable = 69

Service unavailable (69)

  • Required service not running
  • Dependency not available
  • External service unreachable
§

Software = 70

Internal software error (70)

  • Unexpected error
  • Assertion failure
  • Internal consistency check failed
§

OsError = 71

System error (71)

  • OS error
  • System call failed
  • Fork failed
§

OsFile = 72

Critical OS file missing (72)

  • Required system file not found
  • Missing configuration file
§

CantCreate = 73

Cannot create output file (73)

  • Cannot write output
  • Disk full
  • Permission denied on output
§

IoError = 74

I/O error (74)

  • Read error
  • Write error
  • Network I/O error
§

TempFail = 75

Temporary failure, retry (75)

  • Resource temporarily unavailable
  • Retry operation
§

Protocol = 76

Remote error in protocol (76)

  • Protocol violation
  • Invalid response
  • Communication error
§

NoPerm = 77

Permission denied (77)

  • Insufficient privileges
  • Access denied
  • Not authorized
§

Config = 78

Configuration error (78)

  • Invalid configuration
  • Missing required configuration
  • Configuration validation failed
§

Interrupted = 130

Interrupted by signal (SIGINT - Ctrl+C) (130)

  • User interrupted (Ctrl+C)
  • SIGINT received
§

Terminated = 143

Terminated by signal (SIGTERM) (143)

  • SIGTERM received
  • Graceful shutdown requested

Implementations§

Source§

impl ExitCode

Source

pub fn as_i32(self) -> i32

Convert to i32 for use with std::process::exit

Source

pub fn from_error(error: &dyn Error) -> Self

Create ExitCode from error type

Maps common error types to appropriate exit codes:

  • I/O errors → IoError (74)
  • Parse errors → DataError (65)
  • Permission errors → NoPerm (77)
  • Not found errors → NoInput (66)
  • Invalid argument → UsageError (64)
  • Other errors → Error (1)
Source

pub fn description(self) -> &'static str

Get human-readable description of exit code

Source

pub fn is_success(self) -> bool

Check if this is a success exit code

Source

pub fn is_error(self) -> bool

Check if this is an error exit code

Source

pub fn is_signal(self) -> bool

Check if this represents a signal interruption

Trait Implementations§

Source§

impl Clone for ExitCode

Source§

fn clone(&self) -> ExitCode

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ExitCode

Source§

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

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

impl Default for ExitCode

Source§

fn default() -> ExitCode

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

impl Display for ExitCode

Source§

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

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

impl From<ExitCode> for ExitCode

Source§

fn from(code: ExitCode) -> ExitCode

Converts to this type from the input type.
Source§

impl From<ExitCode> for i32

Source§

fn from(code: ExitCode) -> i32

Converts to this type from the input type.
Source§

impl PartialEq for ExitCode

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Copy for ExitCode

Source§

impl Eq for ExitCode

Source§

impl StructuralPartialEq for ExitCode

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more