iTrooz / efivar-rs

EFI boot manager tool written in Rust
MIT License
22 stars 7 forks source link

Unified error handling #2

Closed MOZGIII closed 5 years ago

MOZGIII commented 5 years ago

I have a use case that requires error handling, however I currently have to do target-os dependent conditional compilation to properly handle errors on both linux and windows.

Here's a practical example:

#[cfg(not(target_os = "windows"))]
fn is_no_such_var_error(err: &std::io::Error) -> bool {
    err.kind() == std::io::ErrorKind::NotFound
}

#[cfg(target_os = "windows")]
fn is_no_such_var_error(err: &std::io::Error) -> bool {
    err.kind() == std::io::ErrorKind::Other && err.raw_os_error() == Some(203)
}

I'd appreciate if you add support for unified error type for determining when the variable is not defined.

PS: I'm working on this, come take a look if you're interested.

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 1.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: