Struct std::time::SystemTimeError
1.8.0 · source · [−]pub struct SystemTimeError(_);
Expand description
An error returned from the duration_since
and elapsed
methods on
SystemTime
, used to learn how far in the opposite direction a system time
lies.
Examples
use std::thread::sleep;
use std::time::{Duration, SystemTime};
let sys_time = SystemTime::now();
sleep(Duration::from_secs(1));
let new_sys_time = SystemTime::now();
match sys_time.duration_since(new_sys_time) {
Ok(_) => {}
Err(e) => println!("SystemTimeError difference: {:?}", e.duration()),
}
RunImplementations
sourceimpl SystemTimeError
impl SystemTimeError
sourcepub fn duration(&self) -> Duration
pub fn duration(&self) -> Duration
Returns the positive duration which represents how far forward the second system time was from the first.
A SystemTimeError
is returned from the SystemTime::duration_since
and SystemTime::elapsed
methods whenever the second system time
represents a point later in time than the self
of the method call.
Examples
use std::thread::sleep;
use std::time::{Duration, SystemTime};
let sys_time = SystemTime::now();
sleep(Duration::from_secs(1));
let new_sys_time = SystemTime::now();
match sys_time.duration_since(new_sys_time) {
Ok(_) => {}
Err(e) => println!("SystemTimeError difference: {:?}", e.duration()),
}
RunTrait Implementations
sourceimpl Clone for SystemTimeError
impl Clone for SystemTimeError
sourcefn clone(&self) -> SystemTimeError
fn clone(&self) -> SystemTimeError
Returns a copy of the value. Read more
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for SystemTimeError
impl Debug for SystemTimeError
sourceimpl Display for SystemTimeError
impl Display for SystemTimeError
sourceimpl Error for SystemTimeError
impl Error for SystemTimeError
sourcefn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
1.30.0 · sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
Auto Trait Implementations
impl RefUnwindSafe for SystemTimeError
impl Send for SystemTimeError
impl Sync for SystemTimeError
impl Unpin for SystemTimeError
impl UnwindSafe for SystemTimeError
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more