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

pub struct Timestamp { /* fields omitted */ }
Expand description

Stores the number of nanoseconds from an epoch and a counter for ensuring V1 ids generated on the same host are unique.

Implementations

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.

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).

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.

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).

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.