re_tuid

Struct Tuid

Source
#[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

Source

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

Source

pub const ZERO: Self = _

All zeroes.

Source

pub const MAX: Self = _

All ones.

Source

pub fn new() -> Self

Create a new unique Tuid based on the current time.

Source

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.

Source

pub fn from_u128(id: u128) -> Self

Source

pub fn as_u128(&self) -> u128

Source

pub fn from_bytes(bytes: [u8; 16]) -> Self

Source

pub fn as_bytes(&self) -> [u8; 16]

Returns most significant byte first (big endian).

Source

pub fn nanos_since_epoch(&self) -> u64

Approximate nanoseconds since unix epoch.

The upper 64 bits of the Tuid.

Source

pub fn inc(&self) -> u64

The increment part of the Tuid.

The lower 64 bits of the Tuid.

Source

pub fn next(&self) -> Self

Returns the next logical Tuid.

Wraps the monotonically increasing back to zero on overflow.

Beware: wrong usage can easily lead to conflicts. Prefer Tuid::new when unsure.

Source

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.

Source

pub fn short_string(&self) -> String

A shortened string representation of the Tuid.

Trait Implementations§

Source§

impl Clone for Tuid

Source§

fn clone(&self) -> Tuid

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Tuid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Tuid

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

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§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a Tuid> for Cow<'a, Tuid>

Source§

fn from(value: &'a Tuid) -> Self

Converts to this type from the input type.
Source§

impl From<Tuid> for Cow<'_, Tuid>

Source§

fn from(value: Tuid) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Tuid

Source§

type Err = ParseIntError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Tuid

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

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

impl Ord for Tuid

Source§

fn cmp(&self, other: &Tuid) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Tuid

Source§

fn eq(&self, other: &Tuid) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Tuid

Source§

fn partial_cmp(&self, other: &Tuid) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Tuid

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl SizeBytes for Tuid

Source§

fn heap_size_bytes(&self) -> u64

Returns how many bytes self uses on the heap. Read more
§

fn total_size_bytes(&self) -> u64

Returns the total size of self in bytes, accounting for both stack and heap space.
§

fn stack_size_bytes(&self) -> u64

Returns the total size of self on the stack, in bytes. Read more
§

fn is_pod() -> bool

Is Self just plain old data? Read more
Source§

impl Zeroable for Tuid

§

fn zeroed() -> Self

Source§

impl AnyBitPattern for Tuid

Source§

impl Copy for Tuid

Source§

impl Eq for Tuid

Source§

impl NoUninit for Tuid

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

§

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

If this function returns true, then it must be valid to reinterpret bits as &Self.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<N> NodeTrait for N
where N: Copy + Ord + Hash,

§

impl<T> Ungil for T
where T: Send,