Struct riot_wrappers::error::NumericError
source · pub struct NumericError {
pub number: isize,
}
Expand description
An error that is expressed as a negative number
Ideally, that constraint should be expressed in the type system to allow the compiler to
represent Result<positive_usize, NumericError>
as just the isize it originally was. For the
time being, this works well enough, and performance evaluation can later be done against a
manually implemented newtype around isize that’d be used to represent the Result.
Fields§
§number: isize
Implementations§
source§impl NumericError
impl NumericError
sourcepub const fn from_constant(name: isize) -> Self
pub const fn from_constant(name: isize) -> Self
Construct a NumericError from a riot_sys constant
As error constants are in their unsigned positive form, this flips the argument’s sign into the negative range.
let err = NumericError::from_constant(riot_sys::ENOTSUP as _);
println!("{:?}", err); // NumericError { number: -61 }
Panics
In debug mode, this ensures that the given error is greater than zero.
sourcepub fn again_is_wouldblock(self) -> Error<Self>
pub fn again_is_wouldblock(self) -> Error<Self>
Convert the error into an nb::Error that is nb::Error::WouldBlock if the error is
-EAGAIN
, and an actual error otherwise.
Trait Implementations§
source§impl Debug for NumericError
impl Debug for NumericError
source§impl From<NumericError> for Error
Available on riot_module_bluetil_ad
only.
impl From<NumericError> for Error
riot_module_bluetil_ad
only.source§fn from(e: NumericError) -> Error
fn from(e: NumericError) -> Error
source§impl PartialEq for NumericError
impl PartialEq for NumericError
source§fn eq(&self, other: &NumericError) -> bool
fn eq(&self, other: &NumericError) -> bool
self
and other
values to be equal, and is used
by ==
.