Struct SystemTimeError

pub struct SystemTimeError(pub(in ::time) Duration);

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

Fields

0: Duration

Implementations

impl SystemTimeError

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

Trait Implementations

impl Clone for SystemTimeError

fn clone(&self) -> SystemTimeError

impl Debug for SystemTimeError

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

impl Display for SystemTimeError

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

impl Error for SystemTimeError

Auto Trait Implementations

impl Freeze for SystemTimeError

impl RefUnwindSafe for SystemTimeError

impl Send for SystemTimeError

impl Sync for SystemTimeError

impl Unpin for SystemTimeError

impl UnsafeUnpin for SystemTimeError

impl UnwindSafe for SystemTimeError

Blanket Implementations

impl<T> Any for SystemTimeError where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for SystemTimeError where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for SystemTimeError where T: ?Sized,

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

impl<T> CloneToUninit for SystemTimeError where T: Clone,

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

impl<T> From<T> for SystemTimeError

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for SystemTimeError where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for SystemTimeError

impl<T> ToOwned for SystemTimeError where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> ToString for SystemTimeError where T: Display + ?Sized,

fn to_string(&self) -> String

impl<T, U> Into<U> for SystemTimeError where U: From<T>,

fn into(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<U> for SystemTimeError where U: Into<T>,

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

impl<T, U> TryInto<U> for SystemTimeError where U: TryFrom<T>,

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