Struct stm32wlxx_hal::subghz::ValueError
source · 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>
impl<T> ValueError<T>
sourcepub const fn too_high(value: T, limit: T) -> ValueError<T>
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());
sourcepub const fn too_low(value: T, limit: T) -> ValueError<T>
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());
sourcepub const fn value(&self) -> &T
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);
sourcepub const fn limit(&self) -> &T
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);
Trait Implementations§
source§impl<T: Clone> Clone for ValueError<T>
impl<T: Clone> Clone for ValueError<T>
source§fn clone(&self) -> ValueError<T>
fn clone(&self) -> ValueError<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: Debug> Debug for ValueError<T>
impl<T: Debug> Debug for ValueError<T>
source§impl<T> Display for ValueError<T>where
T: Display,
impl<T> Display for ValueError<T>where T: Display,
source§impl<T: PartialEq> PartialEq for ValueError<T>
impl<T: PartialEq> PartialEq for ValueError<T>
source§fn eq(&self, other: &ValueError<T>) -> bool
fn eq(&self, other: &ValueError<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl<T: Copy> Copy for ValueError<T>
impl<T: Eq> Eq for ValueError<T>
impl<T> StructuralEq for ValueError<T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more