Trait spectrusty::clock::TimestampOps
source · pub trait TimestampOps: Copy + PartialEq<Self> + Eq + PartialOrd<Self> + Ord + Debug + Add<i32, Output = Self> + Sub<i32, Output = Self> + AddAssign<i32> + SubAssign<i32> {
fn from_tstates(ts: i32) -> Self;
fn into_tstates(self) -> i32;
fn max_value() -> Self;
fn min_value() -> Self;
fn diff_from(self, ts_from: Self) -> i32;
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§
sourcefn from_tstates(ts: i32) -> Self
fn from_tstates(ts: i32) -> Self
Returns a normalized timestamp from the given number of T-states.
Panics
Panics when the given ts
overflows the capacity of the timestamp.
sourcefn into_tstates(self) -> i32
fn into_tstates(self) -> i32
sourcefn max_value() -> Self
fn max_value() -> Self
Returns the largest value that can be represented by a normalized timestamp.
sourcefn min_value() -> Self
fn min_value() -> Self
Returns the smallest value that can be represented by a normalized timestamp.
sourcefn diff_from(self, ts_from: Self) -> i32
fn diff_from(self, ts_from: Self) -> i32
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.
sourcefn saturating_add(self, other: Self) -> Self
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.
sourcefn saturating_sub(self, other: Self) -> Self
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.