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 PartialEq for Duration
impl PartialEq for Duration
source§impl PartialOrd for Duration
impl PartialOrd for Duration
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§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