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§

source

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.

source

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§

source

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).

Implementations on Foreign Types§

source§

impl TemporalSample for Instant

source§

fn time_since(&self, origin: &Self) -> Option<Duration>

source§

fn advanced_by(&self, amount: Duration) -> Self

source§

fn advance_by(&mut self, amount: Duration)

source§

impl TemporalSample for Duration

source§

fn time_since(&self, origin: &Duration) -> Option<Duration>

source§

fn advanced_by(&self, amount: Duration) -> Duration

Implementors§