| Crates.io | rustflake |
| lib.rs | rustflake |
| version | 0.1.1 |
| created_at | 2019-08-04 09:55:40.141512+00 |
| updated_at | 2019-08-04 11:52:03.799442+00 |
| description | Thread-safe 'twitter' snowflakes. |
| homepage | |
| repository | https://github.com/iCrawl/rustflake |
| max_upload_size | |
| id | 154093 |
| size | 6,166 |
Thread-safe "twitter" snowflakes.
By default the original Twitter snowflake format defines:
This crate lets you customize your own epoch and worker/datacenter information.
Add this to your Cargo.toml:
[dependencies]
rustflake = "0.1.0"
and this to your crate root:
use rustflake;
use rustflake::Snowflake;
fn main() {
let mut snowflake = Snowflake::default();
println!("{}", &snowflake.generate());
}
use rustflake::Snowflake;
fn main() {
// Discord Epoch
// Though those are not "real" discord Ids,
// because discord increases the sequence
// for *every* generated Id on that process
let mut snowflake = Snowflake::new(1420070400000, 1, 1);
println!("{}", &snowflake.generate());
}
use rustflake::Snowflake;
fn main() {
// Using a builder approach
let mut snowflake = Snowflake::default()
.epoch(1_564_790_400_000)
.worker_id(2)
.datacenter_id(3);
println!("{}", &snowflake.generate());
}