Enum UUID

Source
pub enum UUID {
    Name {
        name: u64,
        scope: u64,
    },
    Number {
        value1: u64,
        value2: u64,
    },
    Event {
        timestamp: u64,
        origin: u64,
    },
    Derived {
        timestamp: u64,
        origin: u64,
    },
}
Expand description

UUIDs are used by RON to identify types, objects, events, etc.

There are different kinds of UUIDs: Name, number, event and derived.

Any UUID has four parts, two related to its content, and two related to its type.

The type of an UUID is a 2-bit number called the scheme. The subtype of an UUID is a 4-bit number called the variety (currently unsupported). Together, the scheme and variety specify the kind of UUID.

Two other fields describe the actual content of the UUID. Both are 60-bit numbers that can be represented as ten-digit Base64 characters.

That leaves 2 bits to make up a 128-bit number. These 2 bits are always 0 and are provided for backwards compatibility with RFC4122 (variant field).

Variants§

§

Name

Name UUIDs are often used to encode short string atoms, such as types (e.g. lww). The string is read as a Base64-literal to determine the actual (numeric) UUID component. Name UUIDs can be global (e.g. lww = lww$0) or scoped (e.g. dbtest$client1)

Fields

§name: u64

Local name.

§scope: u64

Global namespace/node ID.

§

Number

Number UUIDs encode numbers (e.g. indices into a matrix) and hash values. The meaning of the two values is context-dependent.

Fields

§value1: u64

First value.

§value2: u64

Second value.

§

Event

Event UUIDs are Lamport-timestamps that are used to identify operations and objects. The timestamp is clock-dependent, while the origin is a replica ID.

Fields

§timestamp: u64

Local timestamp.

§origin: u64

Global namespace/node ID.

§

Derived

Derived UUIDs refer to an event ID, without being the event ID.

Fields

§timestamp: u64

Local timestamp.

§origin: u64

Global namespace/node ID.

Implementations§

Source§

impl UUID

Source

pub fn set_node_id(val: u64)

Sets the default UUID origin. s must not be longer than 10 characters and only consist of [0-9a-zA-Z~_].

Source

pub fn node_id() -> u64

The current default UUID origin. Initially “0”.

Source

pub fn now() -> Self

New UUID with the default origin (see node_id and set_node_id) and the current time. Ignoring leap seconds and other events that mess with the system time all calls to this functions return unique UUID (duh).

Source

pub fn zero() -> Self

Creates a new 0 UUID

Source

pub fn is_name(&self) -> bool

Return true if and only if this is a name UUID.

Source

pub fn is_number(&self) -> bool

Return true if and only if this is a number UUID.

Source

pub fn is_event(&self) -> bool

Return true if and only if this is an event UUID.

Source

pub fn is_derived(&self) -> bool

Return true if and only if this is a derived UUID.

Source

pub fn is_zero(&self) -> bool

Returns true if high() = low() = 0.

Source

pub fn weak_cmp(a: &UUID, b: &UUID) -> Ordering

Compares a and b while ignoring the scheme.

Source

pub fn parse<'a>( input: &'a str, context: Option<(&UUID, &UUID)>, ) -> Option<(UUID, &'a str)>

Parse a single UUID and return the remaining string. The context argument is the pair previous column UUID / previous row UUID or None.

Source

pub fn compress(&self, context: Option<(&UUID, &UUID)>) -> String

Serialize this UUID the text optionally compressing it against (previous column UUID / previous row UUID) if context is not None.

Trait Implementations§

Source§

impl Arbitrary for UUID

Source§

fn arbitrary<G: Gen>(g: &mut G) -> Self

Source§

fn shrink(&self) -> Box<dyn Iterator<Item = Self>>

Source§

impl Clone for UUID

Source§

fn clone(&self) -> UUID

Returns a duplicate 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 UUID

Source§

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

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

impl Default for UUID

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for UUID

Source§

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

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

impl FromStr for UUID

Source§

type Err = ()

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 UUID

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 UUID

Source§

fn cmp(&self, other: &UUID) -> 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 UUID

Source§

fn eq(&self, other: &UUID) -> 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 UUID

Source§

fn partial_cmp(&self, other: &UUID) -> 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 Copy for UUID

Source§

impl Eq for UUID

Source§

impl StructuralPartialEq for UUID

Auto Trait Implementations§

§

impl Freeze for UUID

§

impl RefUnwindSafe for UUID

§

impl Send for UUID

§

impl Sync for UUID

§

impl Unpin for UUID

§

impl UnwindSafe for UUID

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
Source§

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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§

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.