Skip to content

Barebone snowflake ID generator, written entirely in safe Rust and 0 dependency.

License

Notifications You must be signed in to change notification settings

Liminova/snowflake-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

snowflake-rs

This crate is as completed as my current knowledge allows. It's free of unsafe code for extreme performance tweaks, has zero dependencies, and the compiler doesn't scream at me. Going forward, expect only Rust edition bumps and bug fixes (as if there were any).

Usage

cargo add --git https://github.com/Liminova/snowflake-rs
use snowflake_rs::Snowflake;

let datacenter_id = 1;
let worker_id = 1;
let sequence = 0;

let snowflake = Snowflake::new(datacenter_id, worker_id, sequence).build().unwrap();

let id = snowflake.generate_id();

License

This project is licensed under the MIT license.