atomic-snowflake 11.1.0

Zero-dependency lock-free monotonic 64-bit Snowflake ID, 128-bit ULID, and RFC 9562 UUIDv7 generators with stack-buffered Crockford Base32 and hyphenated hex codecs.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/// Default Snowflake custom epoch (`2020-01-01T00:00:00Z` in Unix milliseconds).
pub const DEFAULT_SNOWFLAKE_EPOCH_MS: u64 = 1_577_836_800_000;
/// Maximum valid 10-bit worker/node identifier (`1023`).
pub const MAX_NODE_ID: u16 = 1023;
/// Maximum 12-bit sequence number per millisecond (`4095`).
pub const MAX_SEQUENCE: u16 = 4095;

pub(crate) const NODE_BITS: u32 = 10;
pub(crate) const SEQUENCE_BITS: u32 = 12;
pub(crate) const TIMESTAMP_SHIFT: u32 = NODE_BITS + SEQUENCE_BITS;
pub(crate) const NODE_MASK: u64 = (1u64 << NODE_BITS) - 1;
pub(crate) const SEQUENCE_MASK: u64 = (1u64 << SEQUENCE_BITS) - 1;
pub(crate) const TIMESTAMP_MASK: u64 = (1u64 << 41) - 1;
pub(crate) const BASE62_ALPHABET: &[u8; 62] =
    b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
pub(crate) const BASE62_STACK_CAP: usize = 11;