pub struct Instant {
pub millis: i64,
}Expand description
A representation of an absolute time value.
The Instant type is a wrapper around a i64 value that represents a number of milliseconds,
monotonically increasing since an arbitrary moment in time, such as system startup. Note that
not all Instant need to reference the same epoch.
- A value of
0is inherently arbitrary. - A value less than
0indicates a time before the starting point.
Instants from different sources should not be mixed as their reference points may be different and thus yield surprising durations. They may not even advance at the same rate or be steady at all.
Fields§
§millis: i64Milliseconds since the epoch.
Implementations§
Source§impl Instant
impl 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 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 total_millis(&self) -> i64
pub fn total_millis(&self) -> i64
The total number of milliseconds that have passed since the epoch.
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)
Performs the
+= operation. Read moreSource§impl Ord for Instant
impl Ord for Instant
Source§impl PartialOrd for Instant
impl PartialOrd for Instant
Source§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)
Performs the
-= operation. Read moreimpl Copy for Instant
impl Eq for Instant
impl StructuralPartialEq for Instant
Auto Trait Implementations§
impl Freeze for Instant
impl RefUnwindSafe for Instant
impl Send for Instant
impl Sync for Instant
impl Unpin for Instant
impl UnwindSafe for Instant
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more