SCRU64 ID offers compact, time-ordered unique identifiers generated by distributed nodes. SCRU64 has the following features:
```rust // pass node ID through environment variable std::env::setvar("SCRU64NODE_SPEC", "42/8");
// generate a new identifier object let x = scru64::new(); println!("{x}"); // e.g. "0u2r85hm2pt3" println!("{}", x.to_u64()); // as a 64-bit unsigned integer
// generate a textual representation directly println!("{}", scru64::new_string()); // e.g. "0u2r85hm2pt4" ```
See [SCRU64 Specification] for details.
SCRU64's uniqueness is realm-specific, i.e., dependent on the centralized assignment of node ID to each generator. If you need decentralized, globally unique time-ordered identifiers, consider [SCRU128].
Default features:
std
enables the primary new()
and new_string()
functions and configures
generator::Scru64Generator
with the system clock. Without std
, this crate
provides limited functionality available under no_std
environments.Optional features:
serde
enables serialization/deserialization via serde.tokio
enables the async_tokio::new()
and async_tokio::new_string()
functions, the non-blocking counterpart of new()
and new_string()
.Licensed under the Apache License, Version 2.0.