Crates.io | icechip |
lib.rs | icechip |
version | 0.1.1 |
source | src |
created_at | 2024-09-29 05:54:08.451335 |
updated_at | 2024-09-29 18:33:32.583336 |
description | A mostly true to spec Twitter Snowflake implementation, with multiple modes. |
homepage | |
repository | https://git.cbax.dev/cbax/icechip |
max_upload_size | |
id | 1390623 |
size | 11,412 |
A snowflake library that actually does what it is supposed to.
(Mostly) adheres to the twitter specification, but also has an improved mode.
NOTE: Only enhanced and extended modes are available at this time. Twitter original spec is horridly painful to implement with generics, as it supports both u64 and i64 and ignores the sign bit completely in both modes. (essentially u63 and i64 modes).
u64 or i64 | |||
---|---|---|---|
0-40 | 41-51 | 52-62 | 63 |
time since an epoch in ms | machine id | sequence number | sign |
Utilizes a 64 bit unsigned integer, moves the now spare sign bit and one sequence bit to the machine ID.
u64 | ||
---|---|---|
0-40 | 41-53 | 54-63 |
time since an epoch in ms | machine id | sequence number |
Utilizes a 128 bit unsigned integer. 32bit machine id, 32bit sequence number. (Ought to be enough for anybody™)
u128 | ||
---|---|---|
0-63 | 64-95 | 96-127 |
full unix timestamp ms | machine id | sequence number |
Another good doc explaining the general fuctionality of snowflakes:discord api reference