pub struct ExitCode(/* private fields */);
Expand description
A Unix-like exit code.
Implementations§
Source§impl ExitCode
impl ExitCode
Sourcepub const SUCCESS: Self
pub const SUCCESS: Self
The program terminated successfully.
Corresponds to exit code 0
.
This is the universal success code.
Sourcepub const GENERAL_ERROR: Self
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.
Sourcepub const INVALID_ARGS: Self
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
).
Sourcepub const USAGE: Self
pub const USAGE: Self
The command was used incorrectly.
Corresponds to exit code 64
(EX_USAGE
from sysexits.h
).
Sourcepub const DATA_ERROR: Self
pub const DATA_ERROR: Self
The program received a malformed or invalid input.
Corresponds to exit code 65
(EX_DATAERR
from sysexits.h
).
Sourcepub const NO_INPUT: Self
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
).
Sourcepub const NO_USER: Self
pub const NO_USER: Self
The user specified did not exist.
Corresponds to exit code 67
(EX_NOUSER
from sysexits.h
).
Sourcepub const NO_HOST: Self
pub const NO_HOST: Self
The host specified did not exist.
Corresponds to exit code 68
(EX_NOHOST
from sysexits.h
).
Sourcepub const UNAVAILABLE: Self
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.
Sourcepub const SOFTWARE: Self
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.
Sourcepub const OS_ERROR: Self
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”.
Sourcepub const OS_FILE: Self
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
).
Sourcepub const CANT_CREATE: Self
pub const CANT_CREATE: Self
A (user specified) output file cannot be created.
Corresponds to exit code 73
(EX_CANTCREAT
from sysexits.h
).
Sourcepub const IO_ERROR: Self
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
).
Sourcepub const TEMP_FAIL: Self
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.
Sourcepub const PROTOCOL: Self
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
).
Sourcepub const NO_PERM: Self
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.
Sourcepub const CONFIG: Self
pub const CONFIG: Self
Something was found in an unconfigured or misconfigured state.
Corresponds to exit code 78
(EX_CONFIG
from sysexits.h
).
Sourcepub const COMMAND_CANNOT_EXECUTE: Self
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.
Sourcepub const COMMAND_NOT_FOUND: Self
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
.
Sourcepub const fn from_raw(code: u8) -> Self
pub const fn from_raw(code: u8) -> Self
Creates a new UnixExitCode
from the underlying u8
code.
Sourcepub const fn is_success(&self) -> bool
pub const fn is_success(&self) -> bool
Returns true
if the exit code represents a successful termination.
Sourcepub const fn is_failure(&self) -> bool
pub const fn is_failure(&self) -> bool
Returns true
if the exit code represents a failure termination.
Trait Implementations§
Source§impl RawExitCode for ExitCode
impl RawExitCode for ExitCode
Source§fn from_raw(code: Self::Code) -> Self
fn from_raw(code: Self::Code) -> Self
RawExitCode
from the underlying code.