Trait TimePoint

Source
pub trait TimePoint<Rhs = Self> {
    type Error;

    // Required method
    fn float_duration_since(
        self,
        rhs: Rhs,
    ) -> Result<FloatDuration, Self::Error>;
}
Expand description

A specific point in time.

Types implementing TimePoint can have a FloatDuration computed between them via float_duration_since in either direction.

#Examples

// Don't forget to use TimePoint.
use float_duration::{TimePoint, FloatDuration};
use std::time::Instant;

let start = Instant::now();
perform_expensive_task();

// Computing a duration using `Instant` cannot fail, so it is safe to unwrap.
let elapsed = Instant::now().float_duration_since(start).unwrap();

println!("Took {}.", elapsed);

Required Associated Types§

Source

type Error

The type returned if there is an error computing the duration.

Required Methods§

Source

fn float_duration_since(self, rhs: Rhs) -> Result<FloatDuration, Self::Error>

The amount of time between two TimePoints.

Implementations on Foreign Types§

Source§

impl TimePoint for Instant

Source§

impl TimePoint for SystemTime

Source§

impl TimePoint for NaiveDate

Source§

impl TimePoint for NaiveDateTime

Source§

impl TimePoint for NaiveTime

Source§

impl<Tz: TimeZone> TimePoint for Date<Tz>

Source§

impl<Tz: TimeZone> TimePoint for DateTime<Tz>

Implementors§