pub struct Instant { /* private fields */ }
Expand description
A representation of an absolute time value.
The Instant
type is a wrapper around a i64
value that
represents a number of microseconds, monotonically increasing
since an arbitrary moment in time, such as system startup.
- A value of
0
is inherently arbitrary. - A value less than
0
indicates a time before the starting point.
Implementations§
source§impl Instant
impl Instant
pub const ZERO: Instant = _
sourcepub fn from_micros<T: Into<i64>>(micros: T) -> Instant
pub fn from_micros<T: Into<i64>>(micros: T) -> Instant
Create a new Instant
from a number of microseconds.
pub const fn from_micros_const(micros: i64) -> Instant
sourcepub fn from_millis<T: Into<i64>>(millis: T) -> Instant
pub fn from_millis<T: Into<i64>>(millis: T) -> Instant
Create a new Instant
from a number of milliseconds.
sourcepub const fn from_millis_const(millis: i64) -> Instant
pub const fn from_millis_const(millis: i64) -> Instant
Create a new Instant
from a number of milliseconds.
sourcepub fn from_secs<T: Into<i64>>(secs: T) -> Instant
pub fn from_secs<T: Into<i64>>(secs: T) -> Instant
Create a new Instant
from a number of seconds.
sourcepub fn now() -> Instant
pub fn now() -> Instant
Create a new Instant
from the current std::time::SystemTime.
sourcepub const fn millis(&self) -> i64
pub const fn millis(&self) -> i64
The fractional number of milliseconds that have passed since the beginning of time.
sourcepub const fn micros(&self) -> i64
pub const fn micros(&self) -> i64
The fractional number of microseconds that have passed since the beginning of time.
sourcepub const fn secs(&self) -> i64
pub const fn secs(&self) -> i64
The number of whole seconds that have passed since the beginning of time.
sourcepub const fn total_millis(&self) -> i64
pub const fn total_millis(&self) -> i64
The total number of milliseconds that have passed since the beginning of time.
sourcepub const fn total_micros(&self) -> i64
pub const fn total_micros(&self) -> i64
The total number of milliseconds that have passed since the beginning of time.
Trait Implementations§
source§impl AddAssign<Duration> for Instant
impl AddAssign<Duration> for Instant
source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+=
operation. Read moresource§impl From<Instant> for SystemTime
impl From<Instant> for SystemTime
source§impl From<SystemTime> for Instant
impl From<SystemTime> for Instant
source§fn from(other: SystemTime) -> Instant
fn from(other: SystemTime) -> Instant
source§impl Ord for Instant
impl Ord for Instant
source§impl PartialEq<Instant> for Instant
impl PartialEq<Instant> for Instant
source§impl PartialOrd<Instant> for Instant
impl PartialOrd<Instant> for Instant
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl SubAssign<Duration> for Instant
impl SubAssign<Duration> for Instant
source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-=
operation. Read more