#[repr(C, align(1))]pub struct Tuid {
pub(crate) time_nanos: [u8; 8],
pub(crate) inc: [u8; 8],
}
Expand description
TUID: Time-based Unique Identifier.
Time-ordered globally unique 128-bit identifiers.
The raw bytes of the Tuid
sorts in time order as the Tuid
itself,
and the Tuid
is byte-aligned so you can just transmute between Tuid
and raw bytes.
Fields§
§time_nanos: [u8; 8]
Approximate nanoseconds since epoch.
A big-endian u64 encoded as bytes to keep the alignment of Tuid
to 1.
We use big-endian so that the raw bytes of the Tuid
sorts in time order.
inc: [u8; 8]
Initialized to something random on each thread,
then incremented for each new Tuid
being allocated.
Uses big-endian u64 encoded as bytes to keep the alignment of Tuid
to 1.
We use big-endian so that the raw bytes of the Tuid
sorts in creation order.
Implementations§
Source§impl Tuid
impl Tuid
Sourcepub const ARROW_EXTENSION_NAME: &'static str = "rerun.datatypes.TUID"
pub const ARROW_EXTENSION_NAME: &'static str = "rerun.datatypes.TUID"
We give an actual name to Tuid
, and inject that name into the Arrow datatype extensions,
as a hack so that we can compactly format them when printing Arrow data to the terminal.
Check out re_format_arrow
for context.
Source§impl Tuid
impl Tuid
Sourcepub fn from_nanos_and_inc(time_nanos: u64, inc: u64) -> Self
pub fn from_nanos_and_inc(time_nanos: u64, inc: u64) -> Self
Construct a Tuid
from the upper and lower halves of a u128-bit.
The first should be nano-seconds since epoch.
pub fn from_u128(id: u128) -> Self
pub fn as_u128(&self) -> u128
pub fn from_bytes(bytes: [u8; 16]) -> Self
Sourcepub fn nanos_since_epoch(&self) -> u64
pub fn nanos_since_epoch(&self) -> u64
Approximate nanoseconds since unix epoch.
The upper 64 bits of the Tuid
.
Sourcepub fn incremented_by(&self, n: u64) -> Self
pub fn incremented_by(&self, n: u64) -> Self
Returns the n
-next logical Tuid
.
This is equivalent to calling Tuid::next
n
times.
Wraps the monotonically increasing back to zero on overflow.
Beware: wrong usage can easily lead to conflicts.
Prefer Tuid::new
when unsure.
Sourcepub fn short_string(&self) -> String
pub fn short_string(&self) -> String
A shortened string representation of the Tuid
.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Tuid
impl<'de> Deserialize<'de> for Tuid
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Display for Tuid
impl Display for Tuid
Formats the Tuid
as a hex string.
The format uses upper case for the first 16 hex digits, and lower case for the last 16 hex digits. This is to make it easily distinguished from other hex strings.
Example: 182342300C5F8C327a7b4a6e5a379ac4
Source§impl Ord for Tuid
impl Ord for Tuid
Source§impl PartialOrd for Tuid
impl PartialOrd for Tuid
Source§impl SizeBytes for Tuid
impl SizeBytes for Tuid
Source§fn heap_size_bytes(&self) -> u64
fn heap_size_bytes(&self) -> u64
self
uses on the heap. Read more§fn total_size_bytes(&self) -> u64
fn total_size_bytes(&self) -> u64
self
in bytes, accounting for both stack and heap space.§fn stack_size_bytes(&self) -> u64
fn stack_size_bytes(&self) -> u64
self
on the stack, in bytes. Read moreimpl AnyBitPattern for Tuid
impl Copy for Tuid
impl Eq for Tuid
impl NoUninit for Tuid
impl StructuralPartialEq for Tuid
Auto Trait Implementations§
impl Freeze for Tuid
impl RefUnwindSafe for Tuid
impl Send for Tuid
impl Sync for Tuid
impl Unpin for Tuid
impl UnwindSafe for Tuid
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
§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self
.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.