Trait TimestampOps

Source
pub trait TimestampOps:
    Copy
    + PartialEq
    + Eq
    + PartialOrd
    + Ord
    + Debug
    + Add<FTs, Output = Self>
    + Sub<FTs, Output = Self>
    + AddAssign<FTs>
    + SubAssign<FTs> {
    // Required methods
    fn from_tstates(ts: FTs) -> Self;
    fn into_tstates(self) -> FTs;
    fn max_value() -> Self;
    fn min_value() -> Self;
    fn diff_from(self, ts_from: Self) -> FTs;
    fn saturating_add(self, other: Self) -> Self;
    fn saturating_sub(self, other: Self) -> Self;
}
Expand description

A trait providing calculation methods for timestamps.

Allows BusDevice implementations to depend on a generic timestamp type.

Required Methods§

Source

fn from_tstates(ts: FTs) -> Self

Returns a normalized timestamp from the given number of T-states.

§Panics

Panics when the given ts overflows the capacity of the timestamp.

Source

fn into_tstates(self) -> FTs

Converts the timestamp to FTs.

§Panics

Panics when self overflows the capacity of the result type.

Source

fn max_value() -> Self

Returns the largest value that can be represented by a normalized timestamp.

Source

fn min_value() -> Self

Returns the smallest value that can be represented by a normalized timestamp.

Source

fn diff_from(self, ts_from: Self) -> FTs

Returns the difference between ts_from and self in the number of T-states.

§Panics

May panic if the result would exceed the capacity of the result type.

Source

fn saturating_add(self, other: Self) -> Self

Returns a normalized timestamp after adding other to it.

Saturates at TimestampOps::min_value or TimestampOps::max_value.

Source

fn saturating_sub(self, other: Self) -> Self

Returns a normalized timestamp after subtracting other from it.

Saturates at TimestampOps::min_value or TimestampOps::max_value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§