pub struct Code(_);
Expand description

Process exit code.

Common exit codes:

Implementations

The process exited successfully.

Generic failure.

Create a custom error code

Converts std::process::ExitStatus to Code.

On Unix, if the process was terminated by a fatal signal, the corresponding signal exit code is returned.

exit now!

Convert to Result

Convert to Exit error type

Add user-visible message (like an Error)

Convert to `ExitCode

Convert to raw value

Convert to portable, raw value

Determines if the provided std::process::ExitStatus was successful.

Example:

use std::process;

let exit_status = process::Command::new("true")
    .status()
    .expect("failed to run true(1)");
assert!(proc_exit::Code::from_status(exit_status).is_ok());

Determines if the provided std::process::ExitStatus was unsuccessful.

Example:

use std::process;

let exit_status = process::Command::new("false")
    .status()
    .expect("failed to run false(1)");
assert!(proc_exit::Code::from_status(exit_status).is_err());

Test if provided exit code is portable across platforms.

While Windows has wider types for return codes, Unix OS’s tend to only support 8-bits, stripping off the higher order bits.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Converts std::process::ExitStatus to an exit code by looking at its ExitStatus::code() value.

On Unix, if the process was terminated by a fatal signal, the corresponding signal exit code is returned.

Converts to this type from the input type.

Converts an i32 primitive integer to an exit code.

Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Is called to get the representation of the value as status code. This status code is returned to the operating system. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.