Struct crystalorb::timestamp::Timestamp [−][src]
pub struct Timestamp(_);
Expand description
Represents and identifies a simulation instant.
Implementations
See note about transitivity for Timestamp’s Ord implementation.
Find the corresponding timestamp for the current time in seconds.
Find the corresponding time in seconds for this timestamp. Since timestamps repeat over time, this function returns the time closest to zero. This makes it useful to find the number of seconds between two timestamps.
Example
use crystalorb::timestamp::Timestamp;
use float_cmp::approx_eq;
const TIMESTEP: f64 = 1.0 / 60.0;
// Given two timestamps.
let t1 = Timestamp::default();
let t2 = t1 + 50;
// We can get the seconds between these two timestamps.
let seconds_difference = (t2 - t1).as_seconds(TIMESTEP);
assert!(approx_eq!(f64, seconds_difference, 50.0 / 60.0, ulps=1));
See note about transitivity for Timestamp’s Ord implementation.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Performs the conversion.
Performs the conversion.
Note: This is technically not transitive, since we are doing wrapped differences.
To guarantee transitivity (for example, to use in BTreeMap
s), ensure that all values being
compared against each other are at most std::i16::MAX
length of each other.
(Maybe std::i16::MAX
is off by one, but it is at least on the conservative side)
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for Timestamp
impl UnwindSafe for Timestamp
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more