pub trait PrintableResult<T, S: AsRef<str>> {
// Required methods
fn bail(self, exit_code: i32) -> Result<T, ExitError<S>>;
fn ok_or_eprint(self) -> Option<T>;
fn ok_or_eprint_signal_safe(self) -> Option<T>;
}Expand description
This trait defines a Result with our own PrintableErrno, allowing further conversion to ExitError, or printing and returning and Option.
Required Methods§
Sourcefn bail(self, exit_code: i32) -> Result<T, ExitError<S>>
fn bail(self, exit_code: i32) -> Result<T, ExitError<S>>
Maps the PrintableErrno to an ExitError in order to facilitate bubbling up the error to the appropriate place to quit the program.
Sourcefn ok_or_eprint(self) -> Option<T>
fn ok_or_eprint(self) -> Option<T>
Sourcefn ok_or_eprint_signal_safe(self) -> Option<T>
fn ok_or_eprint_signal_safe(self) -> Option<T>
Same as PrintableResult::ok_or_eprint, but attempts to write() directly
to stderr and not to call any non-signal-safe functions. Useful when one is
the child in a multi-threaded program after a call to fork().
§Safety
The caller must ensure that stderr (fd 2) is open.