Trait ftvf::TemporalSample
source · pub trait TemporalSample: Sized + Clone + PartialOrd + PartialEq {
// Required methods
fn time_since(&self, origin: &Self) -> Option<Duration>;
fn advanced_by(&self, amount: Duration) -> Self;
// Provided method
fn advance_by(&mut self, amount: Duration) { ... }
}
Expand description
A type that represents a particular point in time. You only need to worry about it if you’re implementing your own timing routines.
Required Methods§
sourcefn time_since(&self, origin: &Self) -> Option<Duration>
fn time_since(&self, origin: &Self) -> Option<Duration>
If this TemporalSample is after the given origin, return the
Duration
that has passed since that point. If this TemporalSample is
before the given origin, return None
.
sourcefn advanced_by(&self, amount: Duration) -> Self
fn advanced_by(&self, amount: Duration) -> Self
Return a new TemporalSample that is this much time into the future.
You must have nanosecond precision. If your underlying type does not have nanosecond precision, you must keep track of the residual.
Provided Methods§
sourcefn advance_by(&mut self, amount: Duration)
fn advance_by(&mut self, amount: Duration)
As advanced_by
, but mutates self instead of returning a new value.
The default implementation just does
*self = self.advanced_by(amount)
.