pub struct Code(_);
Expand description
Implementations§
source§impl Code
impl Code
sourcepub fn from_status(status: ExitStatus) -> Self
pub fn from_status(status: ExitStatus) -> Self
Converts std::process::ExitStatus
to Code
.
On Unix, if the process was terminated by a fatal signal, the corresponding signal exit code is returned.
source§impl Code
impl Code
sourcepub fn as_exit_code(self) -> Option<ExitCode>
pub fn as_exit_code(self) -> Option<ExitCode>
Convert to `ExitCode
sourcepub const fn as_portable(self) -> Option<u8>
pub const fn as_portable(self) -> Option<u8>
Convert to portable, raw value
sourcepub const fn is_ok(self) -> bool
pub const fn is_ok(self) -> bool
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());
sourcepub const fn is_err(self) -> bool
pub const fn is_err(self) -> bool
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());
sourcepub const fn is_portable(self) -> bool
pub const fn is_portable(self) -> bool
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§
source§impl From<ExitStatus> for Code
impl From<ExitStatus> for Code
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.
source§fn from(status: ExitStatus) -> Self
fn from(status: ExitStatus) -> Self
Converts to this type from the input type.