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
)
Number
Number UUIDs encode numbers (e.g. indices into a matrix) and hash values. The meaning of the two values is context-dependent.
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.
Derived
Derived UUIDs refer to an event ID, without being the event ID.
Implementations
sourceimpl UUID
impl UUID
sourcepub fn set_node_id(val: u64)
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~_].
sourcepub fn now() -> Self
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).
sourcepub fn is_derived(&self) -> bool
pub fn is_derived(&self) -> bool
Return true if and only if this is a derived UUID.