PrintableResult

Trait PrintableResult 

Source
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§

Source

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.

Source

fn ok_or_eprint(self) -> Option<T>

Consumes the result, prints the error (if present) to stderr, and returns an Option of the underlying value.

§Safety

The caller must ensure that stderr (fd 2) is open.

Source

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.

Implementations on Foreign Types§

Source§

impl<T, S: AsRef<str>> PrintableResult<T, S> for Result<T, PrintableErrno<S>>

Source§

fn bail(self, exit_code: i32) -> Result<T, ExitError<S>>

Source§

fn ok_or_eprint(self) -> Option<T>

Source§

fn ok_or_eprint_signal_safe(self) -> Option<T>

Implementors§