Expand description
A point in time, relative to the unix epoch.
We have our own Timespec struct instead of using one from std or another crate, because:
-
Currently, the standard library doesn’t provide any way to convert a timestamp to a std::time::SystemTime without the possibility of a panic.
-
The time crate does provide a proper Timespec struct, but is deprecated.
-
Time chrono crate is a bit too big of a dependency.
-
The types of the members of libc::timespec aren’t the same on every platform.
The most used time types/libraries seem to provide a way to work with a
timestamp since the unix epoch with separate seconds (i64 or u64) and
nanoseconds (i32 or u32). For example:
chrono::NativeDateTime::from_timestamp(secs, nsecs)
.
Fields
sec: i64
The number of seconds since unix epoch, possibly negative.
nsec: u32
The number of subsecond nanoseconds, 0 <= nsec < 1_000_000_000.
Trait Implementations
sourceimpl Ord for Timespec
impl Ord for Timespec
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
sourceimpl PartialOrd<Timespec> for Timespec
impl PartialOrd<Timespec> for Timespec
sourcefn partial_cmp(&self, other: &Timespec) -> Option<Ordering>
fn partial_cmp(&self, other: &Timespec) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more