Skip to main content

TimeError

Enum TimeError 

Source
#[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: ClockDomain

Domain required by the receiving clock or instant.

§actual: ClockDomain

Domain 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

§current_elapsed: Duration

Current elapsed duration in the manual clock domain.

§requested_elapsed: Duration

Earlier elapsed duration requested by the caller.

§

InvalidInstantOrder

Duration was requested with an earlier instant after the current one.

Fields

§current_elapsed: Duration

Elapsed duration carried by the receiving current instant.

§earlier_elapsed: Duration

Elapsed duration carried by the supplied earlier instant.

§

TimerUnavailable

A timer could not register or complete a requested deadline.

Fields

§source: TimerUnavailableError

Backend error that prevented timer registration or completion.

Trait Implementations§

Source§

impl Debug for TimeError

Source§

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

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

impl Display for TimeError

Source§

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

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

impl Error for TimeError

Source§

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

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<TimerUnavailableError> for TimeError

Source§

fn from(source: TimerUnavailableError) -> Self

Wraps a timer-backend failure as a monotonic time error.

§Parameters
  • source - Timer-backend failure to wrap.
§Returns

A monotonic time error retaining source.

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.