[][src]Struct uuid::v1::Timestamp

pub struct Timestamp { /* fields omitted */ }

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]

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]

impl PartialEq<Timestamp> for Timestamp[src]

impl StructuralEq for Timestamp[src]

impl StructuralPartialEq for Timestamp[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SendSyncUnwindSafe for T where
    T: Send + Sync + UnwindSafe + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.