Struct ExitCode

Source
pub struct ExitCode(/* private fields */);
Expand description

A Unix-like exit code.

Implementations§

Source§

impl ExitCode

Source

pub const SUCCESS: Self

The program terminated successfully.

Corresponds to exit code 0.

This is the universal success code.

Source

pub const GENERAL_ERROR: Self

The program terminated with a general, unspecified error.

Corresponds to exit code 1.

This is a common “catch-all” for general failures.

Source

pub const INVALID_ARGS: Self

The command line arguments were invalid or used incorrectly.

Corresponds to exit code 2.

Often used by shell builtins (e.g., bash’s exit 2 for builtin_status_bad_usage).

Source

pub const USAGE: Self

The command was used incorrectly.

Corresponds to exit code 64 (EX_USAGE from sysexits.h).

Source

pub const DATA_ERROR: Self

The program received a malformed or invalid input.

Corresponds to exit code 65 (EX_DATAERR from sysexits.h).

Source

pub const NO_INPUT: Self

An input file (not a system file) did not exist or was not readable.

Corresponds to exit code 66 (EX_NOINPUT from sysexits.h).

Source

pub const NO_USER: Self

The user specified did not exist.

Corresponds to exit code 67 (EX_NOUSER from sysexits.h).

Source

pub const NO_HOST: Self

The host specified did not exist.

Corresponds to exit code 68 (EX_NOHOST from sysexits.h).

Source

pub const UNAVAILABLE: Self

A server is unavailable.

Corresponds to exit code 69 (EX_UNAVAILABLE from sysexits.h).

Often used when something does not work as expected.

Source

pub const SOFTWARE: Self

An internal software error occurred.

Corresponds to exit code 70 (EX_SOFTWARE from sysexits.h).

Should be limited to non-operating system software errors.

Source

pub const OS_ERROR: Self

An operating system error occurred.

Corresponds to exit code 71 (EX_OSERR from sysexits.h).

Intended to be used for errors such as “cannot fork” or “cannot create pipe”.

Source

pub const OS_FILE: Self

A system file did not exist, cannot be opened, or has an incorrect format.

Corresponds to exit code 72 (EX_OSFILE from sysexits.h).

Source

pub const CANT_CREATE: Self

A (user specified) output file cannot be created.

Corresponds to exit code 73 (EX_CANTCREAT from sysexits.h).

Source

pub const IO_ERROR: Self

An error occurred while reading or writing to a file.

Corresponds to exit code 74 (EX_IOERR from sysexits.h).

Source

pub const TEMP_FAIL: Self

A temporary failure occurred.

Corresponds to exit code 75 (EX_TEMPFAIL from sysexits.h).

The request may be retried later.

Source

pub const PROTOCOL: Self

A remote system returned something that was “not possible” during a protocol exchange.

Corresponds to exit code 76 (EX_PROTOCOL from sysexits.h).

Source

pub const NO_PERM: Self

The user specified did not have sufficient permissions to perform the operation.

Corresponds to exit code 77 (EX_NOPERM from sysexits.h).

Not intended for file system problems, (use ExitCode::NO_INPUT or ExitCode::CANT_CREATE) but for higher-level permissions.

Source

pub const CONFIG: Self

Something was found in an unconfigured or misconfigured state.

Corresponds to exit code 78 (EX_CONFIG from sysexits.h).

Source

pub const COMMAND_CANNOT_EXECUTE: Self

The command was found but could not be executed (e.g. permission denied).

Corresponds to exit code 126.

Often returned by shells when a command is found but not executable.

Source

pub const COMMAND_NOT_FOUND: Self

The command or program could not be found.

Corresponds to exit code 127.

Often returned by shells when a command is not found in PATH.

Source

pub const fn from_raw(code: u8) -> Self

Creates a new UnixExitCode from the underlying u8 code.

Source

pub const fn to_raw(&self) -> u8

Returns the underlying u8 code.

Source

pub const fn is_success(&self) -> bool

Returns true if the exit code represents a successful termination.

Source

pub const fn is_failure(&self) -> bool

Returns true if the exit code represents a failure termination.

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 Display for ExitCode

Source§

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

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

impl From<u8> for ExitCode

Source§

fn from(code: u8) -> Self

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 RawExitCode for ExitCode

Source§

type Code = u8

Underlying code type.
Source§

fn from_raw(code: Self::Code) -> Self

Create a RawExitCode from the underlying code.
Source§

fn to_raw(&self) -> Self::Code

Returns the underlying code.
Source§

fn is_success(&self) -> bool

Returns whether the exit status indicates success.
Source§

fn is_failure(&self) -> bool

Returns whether the exit status indicates failure.
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, 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.