Skip to main content

generate_replica_id

Function generate_replica_id 

Source
pub fn generate_replica_id() -> ReplicaId
Expand description

Generate a unique replica identifier.

Creates a random 64-bit identifier suitable for use as a CRDT replica ID. The generation strategy differs by platform:

  • Native: Combines system time nanoseconds with random bytes via XOR
  • WASM: Uses cryptographic randomness only (no system time access)

Both strategies provide sufficient uniqueness for distributed systems.

§Examples

use logicaffeine_data::generate_replica_id;

let id1 = generate_replica_id();
let id2 = generate_replica_id();
// IDs will differ with extremely high probability

§Panics

Panics if the random number generator fails to provide bytes.