[−][src]Struct r3::time::Duration
Represents a signed time span used by the API surface of the R3 RTOS.
Duration
is backed by i32
and can represent the range
[-35′47.483648″, +35′47.483647″] with microsecond precision.
Implementations
impl Duration
[src]
pub const ZERO: Self
[src]
An empty interval.
pub const MAX: Self
[src]
The large representable positive time span (+35′47.483647″).
pub const MIN: Self
[src]
The large representable negative time span (-35′47.483648″).
pub const fn from_micros(micros: i32) -> Self
[src]
Construct a new Duration
from the specified number of microseconds.
pub const fn from_millis(millis: i32) -> Self
[src]
Construct a new Duration
from the specified number of milliseconds.
Pancis if millis
overflows the representable range of Duration
.
pub const fn from_secs(secs: i32) -> Self
[src]
Construct a new Duration
from the specified number of seconds.
Pancis if secs
overflows the representable range of Duration
.
pub const fn as_micros(self) -> i32
[src]
Get the total number of whole microseconds contained by this Duration
.
pub const fn as_millis(self) -> i32
[src]
Get the total number of whole milliseconds contained by this Duration
.
pub const fn as_secs(self) -> i32
[src]
Get the total number of whole seconds contained by this Duration
.
pub const fn as_secs_f64(self) -> f64
[src]
Get the total number of seconds contained by this Duration
as f64
.
Examples
use r3::time::Duration; let dur = Duration::from_micros(1_201_250_000); assert_eq!(dur.as_secs_f64(), 1201.25);
pub const fn as_secs_f32(self) -> f32
[src]
Get the total number of seconds contained by this Duration
as f32
.
Examples
use r3::time::Duration; let dur = Duration::from_micros(1_201_250_000); assert_eq!(dur.as_secs_f32(), 1201.25);
pub const fn is_positive(self) -> bool
[src]
Return true
if and only if self
is positive.
pub const fn is_negative(self) -> bool
[src]
Return true
if and only if self
is negative.
pub const fn checked_mul(self, other: i32) -> Option<Self>
[src]
Multiply self
by the specified value, returning None
if the result
overflows.
pub const fn checked_div(self, other: i32) -> Option<Self>
[src]
Divide self
by the specified value, returning None
if the result
overflows or other
is zero.
pub const fn checked_abs(self) -> Option<Self>
[src]
Calculate the absolute value of self
, returning None
if
self == MIN
.
pub const fn checked_add(self, other: Self) -> Option<Self>
[src]
Add the specified value to self
, returning None
if the result
overflows.
pub const fn checked_sub(self, other: Self) -> Option<Self>
[src]
Subtract the specified value from self
, returning None
if the result
overflows.
Trait Implementations
impl Add<Duration> for Duration
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self::Output
[src]
Perform a checked addition, panicking on overflow.
impl Add<Duration> for Time
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Duration) -> Self::Output
[src]
Advance the time by duration
and return the result.
impl AddAssign<Duration> for Duration
[src]
fn add_assign(&mut self, rhs: Self)
[src]
Perform a checked addition, panicking on overflow.
impl AddAssign<Duration> for Time
[src]
fn add_assign(&mut self, rhs: Duration)
[src]
Advance the time by duration
in place.
impl Clone for Duration
[src]
fn clone(&self) -> Duration
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Duration
[src]
impl Debug for Duration
[src]
impl Default for Duration
[src]
impl Div<i32> for Duration
[src]
type Output = Duration
The resulting type after applying the /
operator.
fn div(self, rhs: i32) -> Self::Output
[src]
Perform a checked division, panicking on overflow or when rhs
is zero.
impl DivAssign<i32> for Duration
[src]
fn div_assign(&mut self, rhs: i32)
[src]
Perform a checked division, panicking on overflow or when rhs
is zero.
impl Eq for Duration
[src]
impl From<Duration> for Duration
[src]
fn from(value: Duration) -> Self
[src]
Construct a chrono::Duration
from the specified Duration
.
Examples
use chrono::Duration as ChronoDuration; use r3::time::Duration as OsDuration; assert_eq!( ChronoDuration::from(OsDuration::from_micros(123_456)), ChronoDuration::microseconds(123_456), );
impl Hash for Duration
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Init for Duration
[src]
impl Mul<Duration> for i32
[src]
type Output = Duration
The resulting type after applying the *
operator.
fn mul(self, rhs: Duration) -> Self::Output
[src]
Perform a checked multiplication, panicking on overflow.
impl Mul<i32> for Duration
[src]
type Output = Duration
The resulting type after applying the *
operator.
fn mul(self, rhs: i32) -> Self::Output
[src]
Perform a checked multiplication, panicking on overflow.
impl MulAssign<i32> for Duration
[src]
fn mul_assign(&mut self, rhs: i32)
[src]
Perform a checked multiplication, panicking on overflow.
impl Ord for Duration
[src]
fn cmp(&self, other: &Duration) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Duration> for Duration
[src]
impl PartialOrd<Duration> for Duration
[src]
fn partial_cmp(&self, other: &Duration) -> Option<Ordering>
[src]
fn lt(&self, other: &Duration) -> bool
[src]
fn le(&self, other: &Duration) -> bool
[src]
fn gt(&self, other: &Duration) -> bool
[src]
fn ge(&self, other: &Duration) -> bool
[src]
impl StructuralEq for Duration
[src]
impl StructuralPartialEq for Duration
[src]
impl Sub<Duration> for Duration
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self::Output
[src]
Perform a checked subtraction, panicking on overflow.
impl Sub<Duration> for Time
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Duration) -> Self::Output
[src]
Put back the time by duration
and return the result.
impl SubAssign<Duration> for Duration
[src]
fn sub_assign(&mut self, rhs: Self)
[src]
Perform a checked subtraction, panicking on overflow.
impl SubAssign<Duration> for Time
[src]
fn sub_assign(&mut self, rhs: Duration)
[src]
Put back the time by duration
in place.
impl<'a> Sum<&'a Duration> for Duration
[src]
fn sum<I: Iterator<Item = &'a Duration>>(iter: I) -> Self
[src]
Perform a checked summation, panicking on overflow.
impl Sum<Duration> for Duration
[src]
fn sum<I: Iterator<Item = Duration>>(iter: I) -> Self
[src]
Perform a checked summation, panicking on overflow.
impl TryFrom<Duration> for Duration
[src]
type Error = TryFromDurationError
The type returned in the event of a conversion error.
fn try_from(value: Duration) -> Result<Self, Self::Error>
[src]
Try to construct a Duration
from the specified core::time::Duration
.
Returns an error if the specified Duration
overflows the representable
range of the destination type.
The sub-microsecond part is rounded by truncating.
impl TryFrom<Duration> for Duration
[src]
type Error = TryFromDurationError
The type returned in the event of a conversion error.
fn try_from(value: Duration) -> Result<Self, Self::Error>
[src]
Try to construct a core::time::Duration
from the specified Duration
.
Returns an error if the specified Duration
represents a negative time
span.
impl TryFrom<Duration> for Duration
[src]
type Error = TryFromDurationError
The type returned in the event of a conversion error.
fn try_from(value: Duration) -> Result<Self, Self::Error>
[src]
Try to construct a Duration
from the specified chrono::Duration
.
Returns an error if the specified Duration
overflows the representable
range of the destination type.
The sub-microsecond part is rounded by truncating.
Examples
use std::convert::TryFrom; use chrono::Duration as ChronoDuration; use r3::time::Duration as OsDuration; assert_eq!( OsDuration::try_from(ChronoDuration::nanoseconds(123_456)), Ok(OsDuration::from_micros(123)), ); assert_eq!( OsDuration::try_from(ChronoDuration::nanoseconds(-123_456)), Ok(OsDuration::from_micros(-123)), ); assert!( OsDuration::try_from(ChronoDuration::microseconds(0x100000000)) .is_err() );
impl ZeroInit for Duration
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,