pub trait ResultExt<Output, ErrData: Debug> {
    fn status(&self) -> Status;
fn discard_errdata(self) -> Result<Output>;
fn handle_warning<O>(self, op: O) -> Result<Output, ErrData>
    where
        O: FnOnce(Error<ErrData>) -> Result<Output, ErrData>
; }
Expand description

Extension trait which provides some convenience methods for Result.

Required methods

Extract the UEFI status from this result

Transform the ErrData value to ()

Calls op if the result contains a warning, otherwise returns the result unchanged.

By default warning statuses are treated as errors (i.e. stored in the Err variant) because they generally indicate an abnormal situation. In rare cases though it may be helpful to handle a warning. This method is similar to Result::or_else, except that op is called only when the status is a warning.

Example
use uefi::{Result, ResultExt, Status};

// Treat a specific warning as success, propagate others as errors.
some_result.handle_warning(|err| {
    if err.status() == Status::WARN_RESET_REQUIRED {
        Ok(())
    } else {
        Err(err)
    }
})?;

Implementors