pub struct Instant(/* private fields */);Expand description
A measurement of a monotonically nondecreasing clock. Opaque and useful only with std::time::Duration.
Implementations§
Source§impl Instant
impl Instant
Sourcepub fn elapsed(&self) -> Duration
pub fn elapsed(&self) -> Duration
Returns the amount of time elapsed since this instant was created, or zero duration if this instant is in the future.
Sourcepub fn checked_add(&self, duration: Duration) -> Option<Self>
pub fn checked_add(&self, duration: Duration) -> Option<Self>
Returns Some(T) where t is the time self + durationift can be represented as [Instant], otherwise None`.
Sourcepub fn checked_sub(&self, duration: Duration) -> Option<Self>
pub fn checked_sub(&self, duration: Duration) -> Option<Self>
Returns Some(T) where t is the time self - durationift can be represented as [Instant], otherwise None`.
pub fn duration_since(&self, earlier: Instant) -> Duration
Sourcepub fn checked_duration_since(&self, earlier: Instant) -> Option<Duration>
pub fn checked_duration_since(&self, earlier: Instant) -> Option<Duration>
Returns the duration since earlier if earlier is before self, otherwise returns None.
Sourcepub fn saturating_duration_since(&self, earlier: Instant) -> Duration
pub fn saturating_duration_since(&self, earlier: Instant) -> Duration
Returns the amount of time elapsed from another instant to this one, or zero duration if that instant is later than this one.
Trait Implementations§
Source§impl AddAssign<Duration> for Instant
impl AddAssign<Duration> for Instant
Source§fn add_assign(&mut self, other: Duration)
fn add_assign(&mut self, other: Duration)
Performs the
+= operation. Read moreSource§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, other: Duration)
fn sub_assign(&mut self, other: Duration)
Performs the
-= operation. Read moreSource§impl Unwrap for Instant
impl Unwrap for Instant
type StdImpl = Instant
type TokioImpl = Instant
Source§fn unwrap_std(self) -> Self::StdImpl
fn unwrap_std(self) -> Self::StdImpl
Unwraps the std underlying implementation of the MaybeFut type.
Source§fn unwrap_tokio(self) -> Self::TokioImpl
fn unwrap_tokio(self) -> Self::TokioImpl
Unwraps the tokio underlying implementation of the MaybeFut type.
Source§fn unwrap_std_ref(&self) -> &Self::StdImpl
fn unwrap_std_ref(&self) -> &Self::StdImpl
Unwraps the std underlying implementation of the MaybeFut type as a reference.
Source§fn unwrap_tokio_ref(&self) -> &Self::TokioImpl
fn unwrap_tokio_ref(&self) -> &Self::TokioImpl
Unwraps the tokio underlying implementation of the MaybeFut type as a reference.
Source§fn unwrap_std_mut(&mut self) -> &mut Self::StdImpl
fn unwrap_std_mut(&mut self) -> &mut Self::StdImpl
Unwraps the std underlying implementation of the MaybeFut type as a mutable reference.
Source§fn unwrap_tokio_mut(&mut self) -> &mut Self::TokioImpl
fn unwrap_tokio_mut(&mut self) -> &mut Self::TokioImpl
Unwraps the tokio underlying implementation of the MaybeFut type as a mutable reference.
Source§fn get_std(self) -> Option<Self::StdImpl>
fn get_std(self) -> Option<Self::StdImpl>
Safely unwraps the std underlying implementation of the MaybeFut type.
Source§fn get_tokio(self) -> Option<Self::TokioImpl>
fn get_tokio(self) -> Option<Self::TokioImpl>
Safely unwraps the tokio underlying implementation of the MaybeFut type.
Source§fn get_std_ref(&self) -> Option<&Self::StdImpl>
fn get_std_ref(&self) -> Option<&Self::StdImpl>
Safely unwraps the std underlying implementation of the MaybeFut type as a reference.
Source§fn get_tokio_ref(&self) -> Option<&Self::TokioImpl>
fn get_tokio_ref(&self) -> Option<&Self::TokioImpl>
Safely unwraps the tokio underlying implementation of the MaybeFut type as a reference.
Source§fn get_std_mut(&mut self) -> Option<&mut Self::StdImpl>
fn get_std_mut(&mut self) -> Option<&mut Self::StdImpl>
Safely unwraps the std underlying implementation of the MaybeFut type as a mutable reference.
Source§fn get_tokio_mut(&mut self) -> Option<&mut Self::TokioImpl>
fn get_tokio_mut(&mut self) -> Option<&mut Self::TokioImpl>
Safely unwraps the tokio underlying implementation of the MaybeFut type as a mutable reference.
impl 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