rust-vmm / vmm-sys-util

Helpers and utilities used by multiple rust-vmm components and VMMs
BSD 3-Clause "New" or "Revised" License
79 stars 64 forks source link

Replace `errno::Error` with `io::Error`? #76

Closed exrook closed 3 years ago

exrook commented 4 years ago

Is there a reason errno::Error is used instead of std::io::Error?

I've created a branch replacing errno::Error with io::Error. The main changes were: replacing errno::Error::new() with io::Error::from_raw_os_error() and replacing errno::Error::last() with errno::Error::last_os_error()

The only major change is that io::Error does not implement PartialEq so either ErrorKind or raw_os_error() needs to be used to compare errors.

This is a breaking change for consumers of this crate, but io::Error provides all the same functionality with different method names, so upgrading should be straightforward.

andreeaflorescu commented 4 years ago

We were previously using io::Error and we switched to errno instead. It was annoying that io::Error does not implement PartialEq, we use it quite a lot to test that the errors returned from a functions are the expected ones.

connorkuehl commented 3 years ago

@exrook Starting from v0.6.1 (80abb6f6264e254fb627d211f62f179ce4299c10), client code should be able to convert between io::Error and errno::Error seamlessly. Does this help your use case?

andreeaflorescu commented 3 years ago

@exrook I'll be closing this, please re-open if it is still needed.