[−][src]Struct uuid::v1::Timestamp
Stores the number of nanoseconds from an epoch and a counter for ensuring V1 ids generated on the same host are unique.
Implementations
impl Timestamp
[src]
pub const fn from_rfc4122(ticks: u64, counter: u16) -> Self
[src]
Construct a Timestamp
from its raw component values: an RFC4122
timestamp and counter.
RFC4122, which defines the V1 UUID, specifies a 60-byte timestamp format as the number of 100-nanosecond intervals elapsed since 00:00:00.00, 15 Oct 1582, "the date of the Gregorian reform of the Christian calendar."
The counter value is used to differentiate between ids generated by
the same host computer in rapid succession (i.e. with the same observed
time). See the ClockSequence
trait for a generic interface to any
counter generators that might be used.
Internally, the timestamp is stored as a u64
. For this reason, dates
prior to October 1582 are not supported.
pub fn from_unix(
context: impl ClockSequence,
seconds: u64,
subsec_nanos: u32
) -> Self
[src]
context: impl ClockSequence,
seconds: u64,
subsec_nanos: u32
) -> Self
Construct a Timestamp
from a unix timestamp and sequence-generating
context
.
A unix timestamp represents the elapsed time since Jan 1 1970. Libc's
clock_gettime
and other popular implementations traditionally
represent this duration as a timespec
: a struct with u64
and
u32
fields representing the seconds, and "subsecond" or fractional
nanoseconds elapsed since the timestamp's second began,
respectively.
This constructs a Timestamp
from the seconds and fractional
nanoseconds of a unix timestamp, converting the duration since 1970
into the number of 100-nanosecond intervals since 00:00:00.00, 15
Oct 1582 specified by RFC4122 and used internally by Timestamp
.
The function is not guaranteed to produce monotonically increasing values however. There is a slight possibility that two successive equal time values could be supplied and the sequence counter wraps back over to 0.
If uniqueness and monotonicity is required, the user is responsible for ensuring that the time value always increases between calls (including between restarts of the process and device).
pub const fn to_rfc4122(&self) -> (u64, u16)
[src]
Returns the raw RFC4122 timestamp and counter values stored by the
Timestamp
.
The timestamp (the first, u64
element in the tuple) represents the
number of 100-nanosecond intervals since 00:00:00.00, 15 Oct 1582.
The counter is used to differentiate between ids generated on the
same host computer with the same observed time.
pub const fn to_unix(&self) -> (u64, u32)
[src]
Returns the timestamp converted to the seconds and fractional nanoseconds since Jan 1 1970.
Internally, the time is stored in 100-nanosecond intervals, thus the maximum precision represented by the fractional nanoseconds value is less than its unit size (100 ns vs. 1 ns).
pub const fn to_unix_nanos(&self) -> u64
[src]
Returns the timestamp converted into nanoseconds elapsed since Jan 1
1970. Internally, the time is stored in 100-nanosecond intervals,
thus the maximum precision represented is less than the units it is
measured in (100 ns vs. 1 ns). The value returned represents the
same duration as Timestamp::to_unix
; this provides it in nanosecond
units for convenience.
Trait Implementations
impl Clone for Timestamp
[src]
impl Copy for Timestamp
[src]
impl Debug for Timestamp
[src]
impl Eq for Timestamp
[src]
impl Hash for Timestamp
[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 PartialEq<Timestamp> for Timestamp
[src]
impl StructuralEq for Timestamp
[src]
impl StructuralPartialEq for Timestamp
[src]
Auto Trait Implementations
impl RefUnwindSafe for Timestamp
[src]
impl Send for Timestamp
[src]
impl Sync for Timestamp
[src]
impl Unpin for Timestamp
[src]
impl UnwindSafe for Timestamp
[src]
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> SendSyncUnwindSafe for T where
T: Send + Sync + UnwindSafe + ?Sized,
[src]
T: Send + Sync + UnwindSafe + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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>,