Open briansmith opened 1 month ago
I like this idea, having something like:
impl Error {
pub const fn from_os_error(i32) -> Self;
pub const fn raw_os_error(self) -> Option<i32>
pub const fn new_custom(u16) -> Self;
const fn new_internal(u16) -> Self;
}
seems reasonable to me. We may want to use i32
consistently for OS errors as that's what libstd uses (and it's the return type of errno
).
EDIT: Should we also remove the Error::code
method?
The
From<NonZeroU32> for Error
implementation doesn't do any checking of its inputs; for example, it doesn't verify that an "internal" error code isn't being used, nor does it verify that any internal error code is actually a valid/known one.I propose:
pub const fn Error::new_custom(value: u16) -> Error
pub const fn Error::new_os(u32) -> Error
with range checking, as done in #441, though #441 doesn't make itpub
.impl From<NonZeroU32> for Error
as#[deprecated]
now.This way, internal errors will eventually only be able to be constructed from within the crate.