[−][src]Struct r3::time::Time
Represents a timestamp used by the API surface of the R3 RTOS.
The origin is application-defined. If an application desires to represent a
calender time using Time
, it's recommended to use the midnight UTC on
January 1, 1970 (a.k.a. “UNIX timestamp”) as the origin.
Time
is backed by u64
and can represent up to 213,503,982 days with
microsecond precision.
Implementations
impl Time
[src]
pub const ZERO: Self
[src]
Zero (the origin).
pub const MAX: Self
[src]
The large representable timestamp.
pub const fn from_micros(micros: u64) -> Self
[src]
Construct a new Time
from the specified number of microseconds.
pub const fn from_millis(millis: u64) -> Self
[src]
Construct a new Time
from the specified number of milliseconds.
Pancis if millis
overflows the representable range of Time
.
pub const fn from_secs(secs: u64) -> Self
[src]
Construct a new Time
from the specified number of seconds.
Pancis if secs
overflows the representable range of Time
.
pub const fn as_micros(self) -> u64
[src]
Get the total number of whole microseconds contained in the time span
between this Time
and Self::ZERO
.
pub const fn as_millis(self) -> u64
[src]
Get the total number of whole milliseconds contained in the time span
between this Time
and Self::ZERO
.
pub const fn as_secs(self) -> u64
[src]
Get the total number of whole seconds contained in the time span
between this Time
and Self::ZERO
.
pub const fn as_secs_f64(self) -> f64
[src]
Get the total number of seconds contained in the time span between this
Time
and Self::ZERO
as f64
.
Examples
use r3::time::Time; let dur = Time::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 in the time span between this
Time
and Self::ZERO
as f32
.
Examples
use r3::time::Time; let dur = Time::from_micros(1_201_250_000); assert_eq!(dur.as_secs_f32(), 1201.25);
pub const fn core_duration_since_origin(self) -> Duration
[src]
Get the duration since the origin as ::core::time::Duration
.
pub const fn core_duration_since(self, reference: Self) -> Option<Duration>
[src]
Get the duration since the specified timestamp as
::core::time::Duration
. Returns None
if self
< reference
.
pub fn duration_since(self, reference: Self) -> Option<Duration>
[src]
Get the duration since the specified timestamp as Duration
. Returns
None
if the result overflows the representable range of Duration
.
pub const fn wrapping_add(&self, duration: Duration) -> Self
[src]
Advance the time by duration
and return the result.
pub const fn wrapping_sub(&self, duration: Duration) -> Self
[src]
Put back the time by duration
and return the result.
Trait Implementations
impl Add<Duration> for Time
[src]
type Output = Self
The resulting type after applying the +
operator.
pub fn add(self, rhs: Duration) -> Self::Output
[src]
Advance the time by duration
and return the result.
impl AddAssign<Duration> for Time
[src]
pub fn add_assign(&mut self, rhs: Duration)
[src]
Advance the time by duration
in place.
impl Clone for Time
[src]
pub fn clone(&self) -> Time
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Time
[src]
impl Debug for Time
[src]
impl Default for Time
[src]
impl Eq for Time
[src]
impl Hash for Time
[src]
pub fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Init for Time
[src]
impl Ord for Time
[src]
pub fn cmp(&self, other: &Time) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<Time> for Time
[src]
impl PartialOrd<Time> for Time
[src]
pub fn partial_cmp(&self, other: &Time) -> Option<Ordering>
[src]
pub fn lt(&self, other: &Time) -> bool
[src]
pub fn le(&self, other: &Time) -> bool
[src]
pub fn gt(&self, other: &Time) -> bool
[src]
pub fn ge(&self, other: &Time) -> bool
[src]
impl StructuralEq for Time
[src]
impl StructuralPartialEq for Time
[src]
impl Sub<Duration> for Time
[src]
type Output = Self
The resulting type after applying the -
operator.
pub fn sub(self, rhs: Duration) -> Self::Output
[src]
Put back the time by duration
and return the result.
impl SubAssign<Duration> for Time
[src]
pub fn sub_assign(&mut self, rhs: Duration)
[src]
Put back the time by duration
in place.
impl TryFrom<DateTime<Utc>> for Time
[src]
type Error = TryFromDateTimeError
The type returned in the event of a conversion error.
pub fn try_from(value: DateTime<Utc>) -> Result<Self, Self::Error>
[src]
Try to construct a Time
from the specified chrono::DateTime<Utc>
.
Returns an error if the specified DateTime
overflows the representable
range of the destination type.
The sub-microsecond part is rounded by truncating.
Examples
use std::convert::TryFrom; use chrono::{DateTime, Utc, TimeZone}; use r3::time::Time; assert_eq!( Time::try_from(Utc.timestamp(4, 123_456)), Ok(Time::from_micros(4_000_123)), ); assert!(Time::try_from(Utc.timestamp(-1, 999_999_999)).is_err());
impl TryFrom<Time> for DateTime<Utc>
[src]
type Error = TryFromDateTimeError
The type returned in the event of a conversion error.
pub fn try_from(value: Time) -> Result<Self, Self::Error>
[src]
Try to construct a chrono::DateTime<chrono::Utc>
from the specified
Time
.
Returns an error if the specified Time
overflows the representable
range of the destination type.
Examples
use std::convert::TryFrom; use chrono::{DateTime, Utc, TimeZone}; use r3::time::Time; assert_eq!( DateTime::try_from(Time::from_micros(123_456_789)), Ok(Utc.timestamp(123, 456_789_000)), ); assert!( DateTime::try_from(Time::from_micros(0xffff_ffff_ffff_ffff)) .is_err() );
impl ZeroInit for Time
[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>,