Skip to main content

Time

Trait Time 

Source
pub trait Time {
    type Instant: Copy;
    type Duration: Copy;

    // Required methods
    fn instant_sub(a: Self::Instant, b: Self::Instant) -> Self::Duration;
    fn duration_sub(a: Self::Duration, b: Self::Duration) -> Self::Duration;
    fn duration_add(a: Self::Duration, b: Self::Duration) -> Self::Duration;
    fn mixed_sub(a: Self::Instant, b: Self::Duration) -> Self::Instant;
    fn mixed_add(a: Self::Instant, b: Self::Duration) -> Self::Instant;
    fn instant_cmp(a: Self::Instant, b: Self::Instant) -> Ordering;
}
Expand description

Arithmetic types and operations for a clock domain.

Most users will use the provided implementations: std_clocks::InstantTime, std_clocks::SystemTimeTime, and wrapping_u64::WrappingU64Time.

Required Associated Types§

Required Methods§

Source

fn instant_sub(a: Self::Instant, b: Self::Instant) -> Self::Duration

Returns a - b. Behavior when a < b is unspecified: implementations may panic or return a meaningless value. Use instant_cmp to check ordering first if unsure.

Source

fn duration_sub(a: Self::Duration, b: Self::Duration) -> Self::Duration

Returns a - b. Behavior when a < b is unspecified: implementations may panic or return a meaningless value.

Source

fn duration_add(a: Self::Duration, b: Self::Duration) -> Self::Duration

Source

fn mixed_sub(a: Self::Instant, b: Self::Duration) -> Self::Instant

Source

fn mixed_add(a: Self::Instant, b: Self::Duration) -> Self::Instant

Source

fn instant_cmp(a: Self::Instant, b: Self::Instant) -> Ordering

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§