#[non_exhaustive]pub enum TimeError {
ClockDomainMismatch {
expected: ClockDomain,
actual: ClockDomain,
},
InstantOverflow,
CannotMoveBackward {
current_elapsed: Duration,
requested_elapsed: Duration,
},
InvalidInstantOrder {
current_elapsed: Duration,
earlier_elapsed: Duration,
},
TimerUnavailable {
source: TimerUnavailableError,
},
}Expand description
Describes an invalid monotonic-time operation.
Callers must include a wildcard arm when matching this enum so future versions can add errors without breaking downstream code:
use qubit_clock::TimeError;
fn message(error: TimeError) -> &'static str {
match error {
TimeError::ClockDomainMismatch { .. } => "domain mismatch",
TimeError::InstantOverflow => "overflow",
TimeError::CannotMoveBackward { .. } => "backward move",
TimeError::InvalidInstantOrder { .. } => "invalid order",
TimeError::TimerUnavailable { .. } => "timer unavailable",
_ => "other time error",
}
}
assert_eq!("overflow", message(TimeError::InstantOverflow));An exhaustive match is rejected outside this crate because additional variants may be introduced in a compatible release:
ⓘ
use qubit_clock::TimeError;
fn exhaustive_message(error: TimeError) -> &'static str {
match error {
TimeError::ClockDomainMismatch { .. } => "domain mismatch",
TimeError::InstantOverflow => "overflow",
TimeError::CannotMoveBackward { .. } => "backward move",
TimeError::InvalidInstantOrder { .. } => "invalid order",
TimeError::TimerUnavailable { .. } => "timer unavailable",
}
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
ClockDomainMismatch
Two monotonic instants belong to different clock domains.
Fields
§
expected: ClockDomainDomain required by the receiving clock or instant.
§
actual: ClockDomainDomain carried by the supplied instant.
InstantOverflow
A monotonic instant cannot represent the requested result.
CannotMoveBackward
A manual monotonic clock was asked to move backward.
Fields
InvalidInstantOrder
Duration was requested with an earlier instant after the current one.
Fields
A timer could not register or complete a requested deadline.
Trait Implementations§
Source§impl Error for TimeError
impl Error for TimeError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl !RefUnwindSafe for TimeError
impl !UnwindSafe for TimeError
impl Freeze for TimeError
impl Send for TimeError
impl Sync for TimeError
impl Unpin for TimeError
impl UnsafeUnpin for TimeError
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