snowflake_me 2.0.0

A distributed unique ID generator inspired by Twitter's Snowflake
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#![allow(missing_docs)]

use snowflake_me::Snowflake;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let sf = Snowflake::builder()
        .machine_id(&|| Ok(1))
        .data_center_id(&|| Ok(1))
        .finalize()?;

    let id = sf.next_id()?;
    println!("Generated ID: {id}");
    println!("As u64: {}", id.as_u64());
    println!("As hex: {}", id.hex());
    Ok(())
}