1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! # snowflake-gen
//!
//! A configurable Snowflake ID generator for Rust.
//!
//! ## Overview
//!
//! This crate implements the [Snowflake](https://en.wikipedia.org/wiki/Snowflake_ID) algorithm
//! with fully configurable bit allocation so you can tune the balance between:
//!
//! - **Timestamp range** — how far into the future IDs remain valid
//! - **Throughput** — how many IDs per millisecond (sequence bits)
//! - **Node / machine count** — how many distributed generators you can run
//!
//! The classic Twitter layout is used by default:
//!
//! | Field | Bits | Max value |
//! |-------------|------|--------------------|
//! | Timestamp | 41 | ~69 years |
//! | Machine ID | 5 | 31 |
//! | Node ID | 5 | 31 |
//! | Sequence | 12 | 4 096 / ms |
//!
//! ## Quick start
//!
//! ```rust
//! use snowflake_gen::SnowflakeIdGenerator;
//!
//! let mut idgen = SnowflakeIdGenerator::new(1, 1).unwrap();
//! let id = idgen.generate().unwrap();
//! assert!(id > 0);
//! ```
//!
//! ## Custom layout
//!
//! ```rust
//! use snowflake_gen::{BitLayout, SnowflakeIdGenerator};
//!
//! // 10 sequence bits → 1 023 IDs/ms, 8 machine + 7 node bits
//! let layout = BitLayout::new(38, 8, 7, 10).unwrap();
//! let mut idgen = SnowflakeIdGenerator::with_layout(1, 1, layout).unwrap();
//! let id = idgen.generate().unwrap();
//! assert!(id > 0);
//! ```
pub
pub use SnowflakeIdBucket;
pub use SnowflakeError;
pub use ;
pub use ;
pub use BitLayout;
/// Convenience re-exports.