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
impl TimeSpan
Sourcepub const NANOSECOND: Self
pub const NANOSECOND: Self
One nanosecond span. Minimal possible time span supported by this type.
Sourcepub const MICROSECOND: Self
pub const MICROSECOND: Self
One microsecond span.
Sourcepub const MILLISECOND: Self
pub const MILLISECOND: Self
One millisecond span.
Sourcepub const JULIAN_YEAR: Self
pub const JULIAN_YEAR: Self
One Julian year. Average year length in Julian calendar. Defined as 365.25 days.
Sourcepub const GREGORIAN_YEAR: Self
pub const GREGORIAN_YEAR: Self
One Gregorian year. Average year length in Gregorian calendar. Defined as 365.2425 days.
Sourcepub const SOLAR_YEAR: Self
pub const SOLAR_YEAR: Self
One solar year (tropical year). Defined as 365.24219 days.
Sourcepub const YEAR: Self = Self::SOLAR_YEAR
pub const YEAR: Self = Self::SOLAR_YEAR
One year. Closest value to the average length of a year on Earth.
Sourcepub const fn as_millis(&self) -> u64
pub const fn as_millis(&self) -> u64
Returns number of whole milliseconds this value represents.
Sourcepub const fn as_seconds(&self) -> u64
pub const fn as_seconds(&self) -> u64
Returns number of whole seconds this value represents.
Sourcepub const fn as_minutes(&self) -> u64
pub const fn as_minutes(&self) -> u64
Returns number of whole minutes this value represents.
Sourcepub fn as_secs_f32(&self) -> f32
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.
Sourcepub fn as_secs_f64(&self) -> f64
pub fn as_secs_f64(&self) -> f64
Returns number of seconds as high precision floating point value.
Sourcepub const fn checked_add(self, span: TimeSpan) -> Option<TimeSpan>
pub const fn checked_add(self, span: TimeSpan) -> Option<TimeSpan>
Returns checked sum of two time spans.
Sourcepub const fn checked_sub(self, span: TimeSpan) -> Option<TimeSpan>
pub const fn checked_sub(self, span: TimeSpan) -> Option<TimeSpan>
Returns checked difference of two time spans.
Sourcepub const fn checked_mul(self, value: u64) -> Option<TimeSpan>
pub const fn checked_mul(self, value: u64) -> Option<TimeSpan>
Returns checked multiplication of time span by a number.
Sourcepub const fn checked_div(self, value: u64) -> Option<TimeSpan>
pub const fn checked_div(self, value: u64) -> Option<TimeSpan>
Returns checked division of time span by a number.
Sourcepub const fn div(self, value: NonZeroU64) -> TimeSpan
pub const fn div(self, value: NonZeroU64) -> TimeSpan
Returns the result of dividing this time span by a non-zero value.
Sourcepub const fn checked_div_span(self, span: TimeSpan) -> Option<u64>
pub const fn checked_div_span(self, span: TimeSpan) -> Option<u64>
Returns the result of dividing this time span by a non-zero time span.
Sourcepub const fn div_span(self, span: NonZeroTimeSpan) -> u64
pub const fn div_span(self, span: NonZeroTimeSpan) -> u64
Returns the result of dividing this time span by a non-zero time span.
Sourcepub const fn checked_rem(self, value: u64) -> Option<TimeSpan>
pub const fn checked_rem(self, value: u64) -> Option<TimeSpan>
Returns checked remainder of time span divided by a number.
Sourcepub const fn rem(self, value: NonZeroU64) -> TimeSpan
pub const fn rem(self, value: NonZeroU64) -> TimeSpan
Returns the remainder of time span divided by a non-zero value.
Sourcepub const fn checked_rem_span(self, span: TimeSpan) -> Option<TimeSpan>
pub const fn checked_rem_span(self, span: TimeSpan) -> Option<TimeSpan>
Returns checked remainder of time span divided by a non-zero time span.
Sourcepub const fn rem_span(self, span: NonZeroTimeSpan) -> TimeSpan
pub const fn rem_span(self, span: NonZeroTimeSpan) -> TimeSpan
Returns the remainder of time span divided by a non-zero time span.
Trait Implementations§
Source§impl Add<NonZeroTimeSpan> for TimeSpan
impl Add<NonZeroTimeSpan> for TimeSpan
Source§type Output = NonZeroTimeSpan
type Output = NonZeroTimeSpan
+ operator.Source§fn add(self, rhs: NonZeroTimeSpan) -> NonZeroTimeSpan
fn add(self, rhs: NonZeroTimeSpan) -> NonZeroTimeSpan
+ operation. Read moreSource§impl Add<TimeSpan> for NonZeroTimeSpan
impl Add<TimeSpan> for NonZeroTimeSpan
Source§impl AddAssign<NonZeroTimeSpan> for TimeSpan
impl AddAssign<NonZeroTimeSpan> for TimeSpan
Source§fn add_assign(&mut self, rhs: NonZeroTimeSpan)
fn add_assign(&mut self, rhs: NonZeroTimeSpan)
+= operation. Read moreSource§impl AddAssign<TimeSpan> for NonZeroTimeSpan
impl AddAssign<TimeSpan> for NonZeroTimeSpan
Source§fn add_assign(&mut self, rhs: TimeSpan)
fn add_assign(&mut self, rhs: TimeSpan)
+= operation. Read moreSource§impl AddAssign<TimeSpan> for TimeStamp
impl AddAssign<TimeSpan> for TimeStamp
Source§fn add_assign(&mut self, rhs: TimeSpan)
fn add_assign(&mut self, rhs: TimeSpan)
+= operation. Read moreSource§impl AddAssign for TimeSpan
impl AddAssign for TimeSpan
Source§fn add_assign(&mut self, rhs: TimeSpan)
fn add_assign(&mut self, rhs: TimeSpan)
+= operation. Read moreSource§impl Div<NonZeroTimeSpan> for TimeSpan
impl Div<NonZeroTimeSpan> for TimeSpan
Source§impl Div<TimeSpan> for NonZeroTimeSpan
impl Div<TimeSpan> for NonZeroTimeSpan
Source§impl DivAssign<NonZero<u64>> for TimeSpan
impl DivAssign<NonZero<u64>> for TimeSpan
Source§fn div_assign(&mut self, rhs: NonZeroU64)
fn div_assign(&mut self, rhs: NonZeroU64)
/= operation. Read moreSource§impl DivAssign<u64> for TimeSpan
impl DivAssign<u64> for TimeSpan
Source§fn div_assign(&mut self, rhs: u64)
fn div_assign(&mut self, rhs: u64)
/= operation. Read moreSource§impl From<NonZeroTimeSpan> for TimeSpan
impl From<NonZeroTimeSpan> for TimeSpan
Source§fn from(span: NonZeroTimeSpan) -> Self
fn from(span: NonZeroTimeSpan) -> Self
Source§impl Mul<TimeSpan> for NonZeroU64
impl Mul<TimeSpan> for NonZeroU64
Source§impl MulAssign<NonZero<u64>> for TimeSpan
impl MulAssign<NonZero<u64>> for TimeSpan
Source§fn mul_assign(&mut self, rhs: NonZeroU64)
fn mul_assign(&mut self, rhs: NonZeroU64)
*= operation. Read moreSource§impl MulAssign<u64> for TimeSpan
impl MulAssign<u64> for TimeSpan
Source§fn mul_assign(&mut self, rhs: u64)
fn mul_assign(&mut self, rhs: u64)
*= operation. Read moreSource§impl Ord for TimeSpan
impl Ord for TimeSpan
Source§impl PartialOrd for TimeSpan
impl PartialOrd for TimeSpan
Source§impl Rem<NonZeroTimeSpan> for TimeSpan
impl Rem<NonZeroTimeSpan> for TimeSpan
Source§impl Rem<TimeSpan> for NonZeroTimeSpan
impl Rem<TimeSpan> for NonZeroTimeSpan
Source§impl RemAssign<NonZero<u64>> for TimeSpan
impl RemAssign<NonZero<u64>> for TimeSpan
Source§fn rem_assign(&mut self, rhs: NonZeroU64)
fn rem_assign(&mut self, rhs: NonZeroU64)
%= operation. Read moreSource§impl RemAssign<NonZeroTimeSpan> for TimeSpan
impl RemAssign<NonZeroTimeSpan> for TimeSpan
Source§fn rem_assign(&mut self, rhs: NonZeroTimeSpan)
fn rem_assign(&mut self, rhs: NonZeroTimeSpan)
%= operation. Read moreSource§impl RemAssign<u64> for TimeSpan
impl RemAssign<u64> for TimeSpan
Source§fn rem_assign(&mut self, rhs: u64)
fn rem_assign(&mut self, rhs: u64)
%= operation. Read moreSource§impl RemAssign for TimeSpan
impl RemAssign for TimeSpan
Source§fn rem_assign(&mut self, rhs: TimeSpan)
fn rem_assign(&mut self, rhs: TimeSpan)
%= operation. Read moreSource§impl Sub<NonZeroTimeSpan> for TimeSpan
impl Sub<NonZeroTimeSpan> for TimeSpan
Source§impl Sub<TimeSpan> for NonZeroTimeSpan
impl Sub<TimeSpan> for NonZeroTimeSpan
Source§impl SubAssign<NonZeroTimeSpan> for TimeSpan
impl SubAssign<NonZeroTimeSpan> for TimeSpan
Source§fn sub_assign(&mut self, rhs: NonZeroTimeSpan)
fn sub_assign(&mut self, rhs: NonZeroTimeSpan)
-= operation. Read moreSource§impl SubAssign for TimeSpan
impl SubAssign for TimeSpan
Source§fn sub_assign(&mut self, rhs: TimeSpan)
fn sub_assign(&mut self, rhs: TimeSpan)
-= operation. Read more