Crates.io | chronoflake |
lib.rs | chronoflake |
version | 1.0.1 |
source | src |
created_at | 2023-09-21 22:02:03.448743 |
updated_at | 2024-01-15 17:26:38.832616 |
description | Generate unique IDs based on the Snowflake algorithm |
homepage | https://github.com/Tyrannican/chronoflake |
repository | https://github.com/Tyrannican/chronoflake |
max_upload_size | |
id | 980111 |
size | 17,585 |
Crate to generate unique 64-bit IDs in centralised or decentralised systems.
Based on the Twitter Snowflake algorithm.
use chronoflake::IdGenerator;
const MACHINE_ID: u16 = 49;
fn main() {
// Create an ID generator using the default (Twitter) epoch
let mut cf = IdGenerator::new(MACHINE_ID);
// Generate a unique ID
let id = cf.generate_id();
// Futher processing...
}