pub struct Time { /* private fields */ }Expand description
An absolute point in time represented as nanoseconds since the UNIX epoch.
Used in DDS for sample source timestamps and other time-stamped metadata.
Implementations§
Source§impl Time
impl Time
Sourcepub const NEVER: Self
pub const NEVER: Self
A sentinel value representing a time that will never occur.
Used in DDS APIs to indicate an invalid or unset timestamp.
Sourcepub const fn from_nanos(nanos: i64) -> Self
pub const fn from_nanos(nanos: i64) -> Self
Sourcepub const fn from_millis(millis: i64) -> Self
pub const fn from_millis(millis: i64) -> Self
Sourcepub const fn as_nanos(&self) -> i64
pub const fn as_nanos(&self) -> i64
Returns the timestamp as nanoseconds since the UNIX epoch.
§Examples
use cyclonedds::Time;
let t = Time::from_secs(1);
assert_eq!(t.as_nanos(), 1_000_000_000);Sourcepub fn elapsed(&self) -> Result<Duration>
pub fn elapsed(&self) -> Result<Duration>
Returns the time elapsed since this timestamp as a Duration.
§Errors
Returns Error::BadParameter if the
system time cannot be converted or if this timestamp is in the future.
Sourcepub fn checked_add(&self, duration: Duration) -> Option<Self>
pub fn checked_add(&self, duration: Duration) -> Option<Self>
Trait Implementations§
impl Copy for Time
impl Eq for Time
Source§impl From<Time> for SystemTime
impl From<Time> for SystemTime
impl StructuralPartialEq for Time
Auto Trait Implementations§
impl Freeze for Time
impl RefUnwindSafe for Time
impl Send for Time
impl Sync for Time
impl Unpin for Time
impl UnsafeUnpin for Time
impl UnwindSafe for Time
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
Mutably borrows from an owned value. Read more