Crates.io | snowflake-multi-threaded |
lib.rs | snowflake-multi-threaded |
version | 0.1.4 |
source | src |
created_at | 2018-03-27 13:19:11.624961 |
updated_at | 2019-07-04 03:51:12.540026 |
description | The rust-lang implementation of Twitter's id generator algorithm snowflake, it thread safety | Twitter 的id生成器算法snowflake的rust-lang 实现 |
homepage | https://github.com/hanskorg/snowflake-rust.git |
repository | https://github.com/hanskorg/snowflake-rust.git |
max_upload_size | |
id | 57752 |
size | 8,287 |
snowflake is a lib for generating unique ID
this project is rust-lang implementation of Twitter's id generator algorithm snowflake
Twitter 的id生成器算法snowflake的rust-lang 实现
Add this to your Cargo.toml
:
[dependencies]
snowflake-multi-threaded = "0.1.0"
let workerId:i64 = 1;
let datacenterId:i64 = 1;
let mut id_gen = SnowFlakeId::new(workerId,datacenterId);
println!("{}", id_gen.generate().unwrap());