pub struct TIME_AT_APP_START { /* private fields */ }Expand description
The time at which the application started.
Methods from Deref<Target = SystemTime>§
pub const UNIX_EPOCH: SystemTime = UNIX_EPOCH
1.8.0 · sourcepub fn duration_since(
&self,
earlier: SystemTime,
) -> Result<Duration, SystemTimeError>
pub fn duration_since( &self, earlier: SystemTime, ) -> Result<Duration, SystemTimeError>
Returns the amount of time elapsed from an earlier point in time.
This function may fail because measurements taken earlier are not
guaranteed to always be before later measurements (due to anomalies such
as the system clock being adjusted either forwards or backwards).
Instant can be used to measure elapsed time without this risk of failure.
If successful, Ok(Duration) is returned where the duration represents
the amount of time elapsed from the specified measurement to this one.
Returns an Err if earlier is later than self, and the error
contains how far from self the time is.
§Examples
use std::time::SystemTime;
let sys_time = SystemTime::now();
let new_sys_time = SystemTime::now();
let difference = new_sys_time.duration_since(sys_time)
.expect("Clock may have gone backwards");
println!("{difference:?}");1.8.0 · sourcepub fn elapsed(&self) -> Result<Duration, SystemTimeError>
pub fn elapsed(&self) -> Result<Duration, SystemTimeError>
Returns the difference from this system time to the current clock time.
This function may fail as the underlying system clock is susceptible to
drift and updates (e.g., the system clock could go backwards), so this
function might not always succeed. If successful, Ok(Duration) is
returned where the duration represents the amount of time elapsed from
this time measurement to the current time.
To measure elapsed time reliably, use Instant instead.
Returns an Err if self is later than the current system time, and
the error contains how far from the current system time self is.
§Examples
use std::thread::sleep;
use std::time::{Duration, SystemTime};
let sys_time = SystemTime::now();
let one_sec = Duration::from_secs(1);
sleep(one_sec);
assert!(sys_time.elapsed().unwrap() >= one_sec);1.34.0 · sourcepub fn checked_add(&self, duration: Duration) -> Option<SystemTime>
pub fn checked_add(&self, duration: Duration) -> Option<SystemTime>
Returns Some(t) where t is the time self + duration if t can be represented as
SystemTime (which means it’s inside the bounds of the underlying data structure), None
otherwise.
1.34.0 · sourcepub fn checked_sub(&self, duration: Duration) -> Option<SystemTime>
pub fn checked_sub(&self, duration: Duration) -> Option<SystemTime>
Returns Some(t) where t is the time self - duration if t can be represented as
SystemTime (which means it’s inside the bounds of the underlying data structure), None
otherwise.
Trait Implementations§
source§impl Deref for TIME_AT_APP_START
impl Deref for TIME_AT_APP_START
source§type Target = SystemTime
type Target = SystemTime
source§fn deref(&self) -> &SystemTime
fn deref(&self) -> &SystemTime
impl LazyStatic for TIME_AT_APP_START
Auto Trait Implementations§
impl Freeze for TIME_AT_APP_START
impl RefUnwindSafe for TIME_AT_APP_START
impl Send for TIME_AT_APP_START
impl Sync for TIME_AT_APP_START
impl Unpin for TIME_AT_APP_START
impl UnwindSafe for TIME_AT_APP_START
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
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more