Unique 64 bit ID generator inspired by twitter snowflake
By default, settings are: * Machine ID - 8 bit (up to 255 machines) * Timestamp subset - 41 bits ~69 years since Unix Epoch * Remaining bits (15) - sequence number
If sequence number is overflowing, generator will wait in chunks of 100 microseconds until next millisecond.
Can be configured: * Machine ID - up to 8 bit * Timestamp subset - from 41 to 43 bits (up to 278 years since Unix Epoch)
Add into your Cargo.toml dependencies:
idgen = "0.1.2"
```rust use idgen::IDGen;
fn main() { let idgen = IDGen::new(128); println!("{}", idgen.new_id()); } ```
Alternatively, it can be configured to have more bits for sequence number with less bits for machine ID:
```rust use idgen::IDGen;
fn main() { let idgen = IDGen::newwithconfig(1, 1, 41); println!("{}", idgen.new_id()); } ```