Trait Timestamp

Source
pub trait Timestamp {
    type Duration: PartialOrd;
    type Error;

    // Required methods
    fn now() -> Self;
    fn duration_since_epoch(self) -> Self::Duration;
    fn duration_since(
        &self,
        other: &Self,
    ) -> Result<Self::Duration, Self::Error>;
}
Expand description

Represents a timestamp.

Required Associated Types§

Required Methods§

Source

fn now() -> Self

Get current timestamp.

Source

fn duration_since_epoch(self) -> Self::Duration

Get duration since start.

Source

fn duration_since(&self, other: &Self) -> Result<Self::Duration, Self::Error>

Get duration since other.

§Errors

This function will return an error if duration between other-self timestamps is negative.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§