pub struct Duration(/* private fields */);Expand description
A span of time, or a difference of two timestamps.
Arithmetic on durations is implemented as saturating.
Implementations§
Source§impl Duration
impl Duration
Sourcepub fn as_seconds(self) -> f64
pub fn as_seconds(self) -> f64
The length of the duration as a floating point number of seconds.
Note: Very large durations will loose precision when converted to a floating point.
Sourcepub fn as_raw_steps(self) -> i128
pub fn as_raw_steps(self) -> i128
The length of the duration in steps (2^-64ths of a second)
Sourcepub fn from_raw_steps(steps: i128) -> Self
pub fn from_raw_steps(steps: i128) -> Self
Create a duration from a length in steps (2^-64ths of a second)
Sourcepub fn from_f64_seconds(value: f64) -> Self
pub fn from_f64_seconds(value: f64) -> Self
Create a duration from a floating point number of seconds.
Note: If the provided value is too large or too small to representable as a duration, the result will be clamped to the maximum or minimum respectively.
Sourcepub const fn from_seconds_nanos(seconds: i64, nanos: u32) -> Self
pub const fn from_seconds_nanos(seconds: i64, nanos: u32) -> Self
Create a duration from a given number of seconds, plus the given number of nanoseconds.
The nanoseconds are always applied in the positive direction, so for
example from_seconds_nanos(-1, 500_000_000) represents minus half a
second.
Trait Implementations§
Source§impl AddAssign for Duration
impl AddAssign for Duration
Source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+= operation. Read moreSource§impl<A> AddAssign<Duration> for Timestamp<A>
impl<A> AddAssign<Duration> for Timestamp<A>
Source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+= operation. Read moreimpl Copy for Duration
impl Eq for Duration
Source§impl MulAssign<i8> for Duration
impl MulAssign<i8> for Duration
Source§fn mul_assign(&mut self, rhs: i8)
fn mul_assign(&mut self, rhs: i8)
*= operation. Read moreSource§impl MulAssign<i16> for Duration
impl MulAssign<i16> for Duration
Source§fn mul_assign(&mut self, rhs: i16)
fn mul_assign(&mut self, rhs: i16)
*= operation. Read moreSource§impl MulAssign<i32> for Duration
impl MulAssign<i32> for Duration
Source§fn mul_assign(&mut self, rhs: i32)
fn mul_assign(&mut self, rhs: i32)
*= operation. Read moreSource§impl MulAssign<i64> for Duration
impl MulAssign<i64> for Duration
Source§fn mul_assign(&mut self, rhs: i64)
fn mul_assign(&mut self, rhs: i64)
*= operation. Read moreSource§impl MulAssign<u8> for Duration
impl MulAssign<u8> for Duration
Source§fn mul_assign(&mut self, rhs: u8)
fn mul_assign(&mut self, rhs: u8)
*= operation. Read moreSource§impl MulAssign<u16> for Duration
impl MulAssign<u16> for Duration
Source§fn mul_assign(&mut self, rhs: u16)
fn mul_assign(&mut self, rhs: u16)
*= operation. Read moreSource§impl MulAssign<u32> for Duration
impl MulAssign<u32> for Duration
Source§fn mul_assign(&mut self, rhs: u32)
fn mul_assign(&mut self, rhs: u32)
*= operation. Read moreSource§impl MulAssign<u64> for Duration
impl MulAssign<u64> for Duration
Source§fn mul_assign(&mut self, rhs: u64)
fn mul_assign(&mut self, rhs: u64)
*= operation. Read more