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 moreimpl Copy for Duration
impl Eq for Duration
impl StructuralPartialEq for Duration
Auto Trait Implementations§
impl Freeze for Duration
impl RefUnwindSafe for Duration
impl Send for Duration
impl Sync for Duration
impl Unpin for Duration
impl UnwindSafe for Duration
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)