Struct SystemTimeError

struct SystemTimeError(_)

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()),
}

Implementations

impl SystemTimeError

fn duration(self: &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()),
}

impl Clone for SystemTimeError

fn clone(self: &Self) -> SystemTimeError

impl Debug for SystemTimeError

fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result

impl Display for SystemTimeError

fn fmt(self: &Self, f: &mut fmt::Formatter<'_>) -> fmt::Result

impl Error for SystemTimeError

impl Freeze for SystemTimeError

impl RefUnwindSafe for SystemTimeError

impl Send for SystemTimeError

impl Sync for SystemTimeError

impl Unpin for SystemTimeError

impl UnwindSafe for SystemTimeError

impl<T> Any for SystemTimeError

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for SystemTimeError

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for SystemTimeError

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for SystemTimeError

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for SystemTimeError

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for SystemTimeError

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for SystemTimeError

fn to_string(self: &Self) -> String

impl<T, U> Into for SystemTimeError

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for SystemTimeError

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for SystemTimeError

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>