riot_wrappers::error

Struct NumericError

Source
pub struct NumericError {
    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

Source

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.

Source

pub const fn number(&self) -> isize

Numeric value of the error

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for NumericError

Available on riot_module_sock_udp and riot_module_sock_aux_local and crate feature with_embedded_nal_async only.
Source§

fn kind(&self) -> ErrorKind

Get the kind of this error.
Source§

impl From<NameContainsIllegalNull> for NumericError

Available on riot_module_vfs only.
Source§

fn from(_: NameContainsIllegalNull) -> NumericError

Converts to this type from the input type.
Source§

impl From<NameTooLong> for NumericError

Available on riot_module_vfs only.
Source§

fn from(_: NameTooLong) -> NumericError

Converts to this type from the input type.
Source§

impl From<NumericError> for Error

Available on riot_module_periph_i2c only.
Source§

fn from(err: NumericError) -> Self

Converts to this type from the input type.
Source§

impl From<NumericError> for Error

Available on riot_module_gcoap only.
Source§

fn from(e: NumericError) -> Error

Converts to this type from the input type.
Source§

impl From<NumericError> for Error

Available on riot_module_bluetil_ad only.
Source§

fn from(e: NumericError) -> Error

Converts to this type from the input type.
Source§

impl PartialEq for NumericError

Source§

fn eq(&self, other: &NumericError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for NumericError

Source§

impl StructuralPartialEq for NumericError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoSwitch for T

Source§

fn into_switch<ActiveLevel>(self) -> Switch<T, ActiveLevel>

Consumes the IoPin returning a Switch of the appropriate ActiveLevel. Read more
Source§

fn into_active_low_switch(self) -> Switch<Self, ActiveLow>
where Self: Sized,

Consumes the IoPin returning a Switch<IoPin, ActiveLow>. Read more
Source§

fn into_active_high_switch(self) -> Switch<Self, ActiveHigh>
where Self: Sized,

Consumes the IoPin returning a Switch<IoPin, ActiveHigh>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 4 bytes