Crates.io | scru64 |
lib.rs | scru64 |
version | 2.0.1 |
source | src |
created_at | 2023-03-15 13:04:35.49693 |
updated_at | 2024-09-15 05:19:41.568549 |
description | SCRU64: Sortable, Clock-based, Realm-specifically Unique identifier |
homepage | |
repository | https://github.com/scru64/rust |
max_upload_size | |
id | 810687 |
size | 103,494 |
SCRU64 ID offers compact, time-ordered unique identifiers generated by distributed nodes. SCRU64 has the following features:
// pass node ID through environment variable
// (e.g., SCRU64_NODE_SPEC=42/8 command ...)
// generate a new identifier object
let x = scru64::new_sync();
println!("{}", x); // e.g., "0u2r85hm2pt3"
println!("{}", x.to_u64()); // as a 64-bit unsigned integer
// generate a textual representation directly
println!("{}", scru64::new_string_sync()); // 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
integrates the library with, among others, the system clock to draw
current timestamps. Without std
, this crate provides limited functionality
available under no_std
environments.global_gen
(implies std
) enables the new()
, new_string()
, new_sync()
,
and new_string_sync()
primary entry point functions as well as the
process-wide global generator under the hood.Optional features:
serde
enables serialization/deserialization via serde.Licensed under the Apache License, Version 2.0.