Enum ron_uuid::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

Fields

name: u64

Local name.

scope: u64

Global namespace/node ID.

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)

Number

Fields

value1: u64

First value.

value2: u64

Second value.

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

Event

Fields

timestamp: u64

Local timestamp.

origin: u64

Global namespace/node ID.

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.

Derived

Fields

timestamp: u64

Local timestamp.

origin: u64

Global namespace/node ID.

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

Implementations

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

The current default UUID origin. Initially “0”.

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

Creates a new 0 UUID

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

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

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

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

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

Compares a and b while ignoring the scheme.

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

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

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
Returns the “default value” for a type. Read more
Formats the value using the given formatter. Read more
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. 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 !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. 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.