#[repr(transparent)]pub struct Timestamp(pub u64);
Expand description
Type representing a Thread timestamp.
Tuple Fields§
§0: u64
Implementations§
Source§impl Timestamp
impl Timestamp
Returns true if this timestamp is authoritative, false otherwise.
Sets or clears the authoritative bit.
Returns this timestamp with the authoritative bit changed as indicated.
Sourcepub fn try_from_system_time(
system_time: SystemTime,
) -> Result<Timestamp, BadSystemTime>
pub fn try_from_system_time( system_time: SystemTime, ) -> Result<Timestamp, BadSystemTime>
Tries to convert a std::time::SystemTime
to a Timestamp
.
Will fail if the given SystemTime cannot be represented as a Timestamp. This
can happen if the SystemTime
represents a time that is before the epoch or is too
far in the future.
Sourcepub fn try_from_duration_since_epoch(
duration: Duration,
) -> Result<Timestamp, BadSystemTime>
pub fn try_from_duration_since_epoch( duration: Duration, ) -> Result<Timestamp, BadSystemTime>
Tries to convert a std::time::Duration
to a Timestamp
.
Will fail if duration is negative or too large.
Sourcepub const fn as_secs(&self) -> u64
pub const fn as_secs(&self) -> u64
Returns the timestamp as the number of seconds since the epoch.
Sourcepub const fn subsec_fraction(&self) -> u64
pub const fn subsec_fraction(&self) -> u64
Returns the subsecond fraction of the timestamp, measured in 1/32768ths of a second.
Sourcepub const fn as_micros(&self) -> u64
pub const fn as_micros(&self) -> u64
Returns the timestamp as the number of microseconds since the epoch.
Sourcepub fn to_system_time(&self) -> SystemTime
pub fn to_system_time(&self) -> SystemTime
Converts this Timestamp into a std::time::SystemTime
;
Sourcepub fn to_duration_since_epoch(&self) -> Duration
pub fn to_duration_since_epoch(&self) -> Duration
Returns this timestamp as a duration since the UNIX epoch (1970-01-01T00:00:00UTC
)
Sourcepub const fn to_be_bytes(&self) -> [u8; 8]
pub const fn to_be_bytes(&self) -> [u8; 8]
Returns the timestamp as big-endian bytes.
Sourcepub const fn to_le_bytes(&self) -> [u8; 8]
pub const fn to_le_bytes(&self) -> [u8; 8]
Returns the timestamp as little-endian bytes.
Sourcepub fn to_naive_date_time(&self) -> NaiveDateTime
pub fn to_naive_date_time(&self) -> NaiveDateTime
Returns the timestamp as an instance of chrono::naive::NaiveDateTime
.
Trait Implementations§
Source§impl AddAssign<Duration> for Timestamp
impl AddAssign<Duration> for Timestamp
Source§fn add_assign(&mut self, duration: Duration)
fn add_assign(&mut self, duration: Duration)
+=
operation. Read moreSource§impl From<Timestamp> for SystemTime
impl From<Timestamp> for SystemTime
Source§impl Ord for Timestamp
impl Ord for Timestamp
Source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
Source§impl TryFrom<SystemTime> for Timestamp
impl TryFrom<SystemTime> for Timestamp
Source§type Error = BadSystemTime
type Error = BadSystemTime
impl Copy for Timestamp
impl Eq for Timestamp
impl StructuralPartialEq for Timestamp
Auto Trait Implementations§
impl Freeze for Timestamp
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnwindSafe for Timestamp
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)