pub struct ValueError<T> { /* private fields */ }
Expand description

Error for a value that is out-of-bounds.

Used by Timeout::from_duration.

Implementations§

source§

impl<T> ValueError<T>

source

pub const fn too_high(value: T, limit: T) -> ValueError<T>

Create a new ValueError for a value that exceeded an upper bound.

Unfortunately panic is not available in const fn, so there are no guarantees on the value being greater than the limit.

Example
use stm32wlxx_hal::subghz::ValueError;

const ERROR: ValueError<u8> = ValueError::too_high(101u8, 100u8);
assert!(ERROR.over());
assert!(!ERROR.under());
source

pub const fn too_low(value: T, limit: T) -> ValueError<T>

Create a new ValueError for a value that exceeded a lower bound.

Unfortunately panic is not available in const fn, so there are no guarantees on the value being less than the limit.

Example
use stm32wlxx_hal::subghz::ValueError;

const ERROR: ValueError<u8> = ValueError::too_low(200u8, 201u8);
assert!(ERROR.under());
assert!(!ERROR.over());
source

pub const fn value(&self) -> &T

Get the value that caused the error.

Example
use stm32wlxx_hal::subghz::ValueError;

const ERROR: ValueError<u8> = ValueError::too_high(101u8, 100u8);
assert_eq!(ERROR.value(), &101u8);
source

pub const fn limit(&self) -> &T

Get the limit for the value.

Example
use stm32wlxx_hal::subghz::ValueError;

const ERROR: ValueError<u8> = ValueError::too_high(101u8, 100u8);
assert_eq!(ERROR.limit(), &100u8);
source

pub const fn over(&self) -> bool

Returns true if the value was over the limit.

Example
use stm32wlxx_hal::subghz::ValueError;

const ERROR: ValueError<u8> = ValueError::too_high(101u8, 100u8);
assert!(ERROR.over());
assert!(!ERROR.under());
source

pub const fn under(&self) -> bool

Returns true if the value was under the limit.

Example
use stm32wlxx_hal::subghz::ValueError;

const ERROR: ValueError<u8> = ValueError::too_low(200u8, 201u8);
assert!(ERROR.under());
assert!(!ERROR.over());

Trait Implementations§

source§

impl<T: Clone> Clone for ValueError<T>

source§

fn clone(&self) -> ValueError<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for ValueError<T>

source§

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

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

impl<T> Display for ValueError<T>where T: Display,

source§

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

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

impl<T: PartialEq> PartialEq for ValueError<T>

source§

fn eq(&self, other: &ValueError<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Copy> Copy for ValueError<T>

source§

impl<T: Eq> Eq for ValueError<T>

source§

impl<T> StructuralEq for ValueError<T>

source§

impl<T> StructuralPartialEq for ValueError<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for ValueError<T>where T: RefUnwindSafe,

§

impl<T> Send for ValueError<T>where T: Send,

§

impl<T> Sync for ValueError<T>where T: Sync,

§

impl<T> Unpin for ValueError<T>where T: Unpin,

§

impl<T> UnwindSafe for ValueError<T>where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.