lattice_core/replica_id
A globally unique identifier for a replica (node) in a distributed system.
Replica IDs are opaque wrappers around strings. Use new to create one
from a string and to_string to extract the underlying value. The opaque
type prevents accidental use of arbitrary strings where a replica ID is
expected.
Example
import lattice_core/replica_id
let rid = replica_id.new("node-a")
replica_id.to_string(rid) // -> "node-a"
Types
Values
pub fn compare(a: ReplicaId, b: ReplicaId) -> order.Order
Compare two ReplicaId values by lexicographic UTF-8 byte order.
Uses the same order on Erlang and JavaScript for deterministic tie-breaking (e.g., in LWW-Register merge when timestamps are equal). Strings retain their original form; no Unicode normalization is applied.
Examples
compare(new("\u{e000}"), new("\u{10000}"))
// -> order.Lt
pub fn decoder() -> decode.Decoder(ReplicaId)
A decoder for ReplicaId values in JSON.
Decodes a JSON string and wraps it in a ReplicaId. Useful as a building
block in from_json decoders across the library.