Struct TimeSpan

Source
pub struct TimeSpan { /* private fields */ }
Expand description

An interval in between time stamps. This type is used to represent durations with nanosecond precision.

Implementations§

Source§

impl TimeSpan

Source

pub const ZERO: Self

Zero time span.

Represents duration between equal time points.

Source

pub const NANOSECOND: Self

One nanosecond span. Minimal possible time span supported by this type.

Source

pub const MICROSECOND: Self

One microsecond span.

Source

pub const MILLISECOND: Self

One millisecond span.

Source

pub const SECOND: Self

One second span.

Source

pub const MINUTE: Self

One minute span.

Source

pub const HOUR: Self

One hour span.

Source

pub const DAY: Self

One day span.

Source

pub const WEEK: Self

One week. Defined as 7 days.

Source

pub const JULIAN_YEAR: Self

One Julian year. Average year length in Julian calendar. Defined as 365.25 days.

Source

pub const GREGORIAN_YEAR: Self

One Gregorian year. Average year length in Gregorian calendar. Defined as 365.2425 days.

Source

pub const SOLAR_YEAR: Self

One solar year (tropical year). Defined as 365.24219 days.

Source

pub const YEAR: Self = Self::SOLAR_YEAR

One year. Closest value to the average length of a year on Earth.

Source

pub const fn new(nanos: u64) -> TimeSpan

Constructs time span from number of nanoseconds.

Source

pub const fn as_nanos(self) -> u64

Returns number of nanoseconds in this time span.

Source

pub const fn as_micros(&self) -> u64

Returns number of microseconds this value represents.

Source

pub const fn as_millis(&self) -> u64

Returns number of whole milliseconds this value represents.

Source

pub const fn as_seconds(&self) -> u64

Returns number of whole seconds this value represents.

Source

pub const fn as_minutes(&self) -> u64

Returns number of whole minutes this value represents.

Source

pub const fn as_hours(&self) -> u64

Returns number of whole hours this value represents.

Source

pub const fn as_days(&self) -> u64

Returns number of whole days this value represents.

Source

pub const fn as_weeks(&self) -> u64

Returns number of whole weeks this value represents.

Source

pub fn as_secs_f32(&self) -> f32

Returns number of seconds as floating point value. This function should be used for small-ish spans when high precision is not required.

Source

pub fn as_secs_f64(&self) -> f64

Returns number of seconds as high precision floating point value.

Source

pub const fn checked_add(self, span: TimeSpan) -> Option<TimeSpan>

Source

pub const fn checked_sub(self, span: TimeSpan) -> Option<TimeSpan>

Source

pub const fn checked_mul(self, value: u64) -> Option<TimeSpan>

Source

pub const fn checked_div(self, value: u64) -> Option<TimeSpan>

Source

pub const fn div(self, value: NonZeroU64) -> TimeSpan

Source

pub const fn checked_div_span(self, span: TimeSpan) -> Option<u64>

Source

pub const fn div_span(self, span: NonZeroTimeSpan) -> u64

Source

pub const fn checked_rem(self, value: u64) -> Option<TimeSpan>

Source

pub const fn rem(self, value: NonZeroU64) -> TimeSpan

Source

pub const fn checked_rem_span(self, span: TimeSpan) -> Option<TimeSpan>

Source

pub const fn rem_span(self, span: NonZeroTimeSpan) -> TimeSpan

Source

pub const fn hms(hours: u64, minutes: u64, seconds: u64) -> TimeSpan

Source

pub const fn dhms(days: u64, hours: u64, minutes: u64, seconds: u64) -> TimeSpan

Trait Implementations§

Source§

impl Add<TimeSpan> for TimeStamp

Source§

type Output = TimeStamp

The resulting type after applying the + operator.
Source§

fn add(self, rhs: TimeSpan) -> Self

Performs the + operation. Read more
Source§

impl Add for TimeSpan

Source§

type Output = TimeSpan

The resulting type after applying the + operator.
Source§

fn add(self, rhs: TimeSpan) -> Self

Performs the + operation. Read more
Source§

impl AddAssign<TimeSpan> for TimeStamp

Source§

fn add_assign(&mut self, rhs: TimeSpan)

Performs the += operation. Read more
Source§

impl AddAssign for TimeSpan

Source§

fn add_assign(&mut self, rhs: TimeSpan)

Performs the += operation. Read more
Source§

impl Clone for TimeSpan

Source§

fn clone(&self) -> TimeSpan

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TimeSpan

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for TimeSpan

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Div<NonZero<u64>> for TimeSpan

Source§

type Output = TimeSpan

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NonZeroU64) -> Self

Performs the / operation. Read more
Source§

impl Div<u64> for TimeSpan

Source§

type Output = TimeSpan

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u64) -> Self

Performs the / operation. Read more
Source§

impl Div for TimeSpan

Source§

type Output = u64

The resulting type after applying the / operator.
Source§

fn div(self, rhs: TimeSpan) -> u64

Performs the / operation. Read more
Source§

impl DivAssign<NonZero<u64>> for TimeSpan

Source§

fn div_assign(&mut self, rhs: NonZeroU64)

Performs the /= operation. Read more
Source§

impl DivAssign<u64> for TimeSpan

Source§

fn div_assign(&mut self, rhs: u64)

Performs the /= operation. Read more
Source§

impl From<Duration> for TimeSpan

Source§

fn from(duration: Duration) -> Self

Converts to this type from the input type.
Source§

impl From<TimeSpan> for Duration

Source§

fn from(span: TimeSpan) -> Self

Converts to this type from the input type.
Source§

impl FromStr for TimeSpan

Source§

type Err = TimeSpanParseErr

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for TimeSpan

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Mul<NonZero<u64>> for TimeSpan

Source§

type Output = TimeSpan

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NonZeroU64) -> Self

Performs the * operation. Read more
Source§

impl Mul<TimeSpan> for NonZeroU64

Source§

type Output = TimeSpan

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: TimeSpan) -> TimeSpan

Performs the * operation. Read more
Source§

impl Mul<TimeSpan> for u64

Source§

type Output = TimeSpan

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: TimeSpan) -> TimeSpan

Performs the * operation. Read more
Source§

impl Mul<u64> for TimeSpan

Source§

type Output = TimeSpan

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u64) -> Self

Performs the * operation. Read more
Source§

impl MulAssign<NonZero<u64>> for TimeSpan

Source§

fn mul_assign(&mut self, rhs: NonZeroU64)

Performs the *= operation. Read more
Source§

impl MulAssign<u64> for TimeSpan

Source§

fn mul_assign(&mut self, rhs: u64)

Performs the *= operation. Read more
Source§

impl Ord for TimeSpan

Source§

fn cmp(&self, other: &TimeSpan) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for TimeSpan

Source§

fn eq(&self, other: &TimeSpan) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for TimeSpan

Source§

fn partial_cmp(&self, other: &TimeSpan) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Rem<NonZero<u64>> for TimeSpan

Source§

type Output = TimeSpan

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: NonZeroU64) -> Self

Performs the % operation. Read more
Source§

impl Rem<u64> for TimeSpan

Source§

type Output = TimeSpan

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: u64) -> Self

Performs the % operation. Read more
Source§

impl Rem for TimeSpan

Source§

type Output = TimeSpan

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: TimeSpan) -> TimeSpan

Performs the % operation. Read more
Source§

impl RemAssign<NonZero<u64>> for TimeSpan

Source§

fn rem_assign(&mut self, rhs: NonZeroU64)

Performs the %= operation. Read more
Source§

impl RemAssign<u64> for TimeSpan

Source§

fn rem_assign(&mut self, rhs: u64)

Performs the %= operation. Read more
Source§

impl RemAssign for TimeSpan

Source§

fn rem_assign(&mut self, rhs: TimeSpan)

Performs the %= operation. Read more
Source§

impl Sub for TimeSpan

Source§

type Output = TimeSpan

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: TimeSpan) -> Self

Performs the - operation. Read more
Source§

impl SubAssign for TimeSpan

Source§

fn sub_assign(&mut self, rhs: TimeSpan)

Performs the -= operation. Read more
Source§

impl Copy for TimeSpan

Source§

impl Eq for TimeSpan

Source§

impl StructuralPartialEq for TimeSpan

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.