pub struct Duration { /* private fields */ }
Expand description
A duration is a span of time that can also be negative.
For example, the difference between two instants is a duration. And an instant plus a duration is another instant.
Implementations§
Source§impl Duration
impl Duration
Sourcepub fn from_seconds(secs: f64) -> Self
pub fn from_seconds(secs: f64) -> Self
Create an instance with the given amount of seconds
Sourcepub fn from_millis(millis: i64) -> Self
pub fn from_millis(millis: i64) -> Self
Create an instance with the given amount of milliseconds
Sourcepub fn from_micros(micros: i64) -> Self
pub fn from_micros(micros: i64) -> Self
Create an instance with the given amount of microseconds
Sourcepub fn from_nanos(nanos: i64) -> Self
pub fn from_nanos(nanos: i64) -> Self
Create an instance with the given amount of nanoseconds
Sourcepub fn from_fixed_nanos<F: ToFixed>(nanos: F) -> Self
pub fn from_fixed_nanos<F: ToFixed>(nanos: F) -> Self
Create an instance with the given amount of nanoseconds, using a fixed point number so the subnanoseconds can be specified as well
Sourcepub fn nanos_rounded(&self) -> i128
pub fn nanos_rounded(&self) -> i128
Get the total amount of nanoseconds dropping any sub nanosecond parts
Sourcepub fn nanos_lossy(&self) -> f64
pub fn nanos_lossy(&self) -> f64
Get the total amount of nanoseconds, losing some precision
Sourcepub fn from_log_interval(log_interval: i8) -> Self
pub fn from_log_interval(log_interval: i8) -> Self
Converts a log interval (as defined by the PTP spec) to a duration
Sourcepub fn from_interval(interval: Interval) -> Self
pub fn from_interval(interval: Interval) -> Self
Converts a interval (as defined by the PTP spec) to a duration
Trait Implementations§
Source§impl AddAssign<Duration> for Time
impl AddAssign<Duration> for Time
Source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+=
operation. Read moreSource§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<TF: ToFixed> DivAssign<TF> for Duration
impl<TF: ToFixed> DivAssign<TF> for Duration
Source§fn div_assign(&mut self, rhs: TF)
fn div_assign(&mut self, rhs: TF)
/=
operation. Read moreSource§impl<TF: ToFixed> MulAssign<TF> for Duration
impl<TF: ToFixed> MulAssign<TF> for Duration
Source§fn mul_assign(&mut self, rhs: TF)
fn mul_assign(&mut self, rhs: TF)
*=
operation. Read moreSource§impl Ord for Duration
impl Ord for Duration
Source§impl PartialOrd for Duration
impl PartialOrd for Duration
Source§impl RemAssign for Duration
impl RemAssign for Duration
Source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
%=
operation. Read moreSource§impl SubAssign<Duration> for Time
impl SubAssign<Duration> for Time
Source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-=
operation. Read moreSource§impl SubAssign for Duration
impl SubAssign for Duration
Source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-=
operation. Read more