pub struct Instant(/* private fields */);Expand description
Represents a time on a monotonically increasing clock (i.e., time since program start).
This type has a precision of 1 microsecond.
Implementations§
Source§impl Instant
impl Instant
Sourcepub fn from_micros(micros: u64) -> Self
pub fn from_micros(micros: u64) -> Self
Creates a new Instant from the specified number of whole
microseconds since program start.
Sourcepub fn from_millis(millis: u64) -> Self
pub fn from_millis(millis: u64) -> Self
Creates a new Instant from the specified number of whole milliseconds
since program start.
Sourcepub fn from_secs(secs: u64) -> Self
pub fn from_secs(secs: u64) -> Self
Creates a new Instant from the specified number of whole seconds since
program start.
Sourcepub fn as_millis(&self) -> u64
pub fn as_millis(&self) -> u64
Returns the number of whole seconds since program start contained by
this Instant.
The returned value does not include the fractional (milliseconds) part of the time value.
Sourcepub fn as_secs(&self) -> u64
pub fn as_secs(&self) -> u64
Returns the number of whole seconds since program start contained by
this Instant.
Sourcepub fn as_micros(&self) -> u64
pub fn as_micros(&self) -> u64
Returns the number of whole microseconds since program start contained
by this Instant.
Sourcepub fn subsec_millis(&self) -> u64
pub fn subsec_millis(&self) -> u64
Returns the fractional part of this Instant, in whole milliseconds.
This method does not return the time value in milliseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one thousand).
Sourcepub fn subsec_micros(&self) -> u64
pub fn subsec_micros(&self) -> u64
Returns the fractional part of this Instant, in whole microseconds.
This method does not return the time value in microseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one million).
Sourcepub fn checked_add(self, rhs: Duration) -> Option<Self>
pub fn checked_add(self, rhs: Duration) -> Option<Self>
Sourcepub fn checked_sub(self, rhs: Duration) -> Option<Instant>
pub fn checked_sub(self, rhs: Duration) -> Option<Instant>
Sourcepub fn checked_sub_instant(self, rhs: Self) -> Option<Duration>
pub fn checked_sub_instant(self, rhs: Self) -> Option<Duration>
Checked subtraction of two Instants. Computes self - rhs, returning
None if the result would be negative or overflow occurred.
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 DivAssign<u64> for Instant
impl DivAssign<u64> for Instant
Source§fn div_assign(&mut self, rhs: u64)
fn div_assign(&mut self, rhs: u64)
/= operation. Read moreSource§impl MulAssign<u64> for Instant
impl MulAssign<u64> for Instant
Source§fn mul_assign(&mut self, rhs: u64)
fn mul_assign(&mut self, rhs: u64)
*= 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)
-= operation. Read more