Snowcloud

Documentation | Crates.io

a small library for implementing custom ids based on timestamps, static ids, and sequence counters. the module provides 2 types of generators, a thread safe and non thread safe version. they allow for different types of waiting for ids if you want specific behavior. each generator is capable of using different snowflake types to allow for different snowflake formats.

```rust // 43 bit timestamp, 8 bit primary id, 12 bit sequence type MyFlake = snowcloud::i64::SingleIdFlake<43, 8, 12>; type MyCloud = snowcloud::Generator;

// 2023/03/23 9:00:00 in milliseconds, timestamps will start from this // date const START_TIME: u64 = 1679587200000;

let mut cloud = MyCloud::new(STARTTIME, 1) .expect("failed to create MyCloud"); let flake = cloud.nextid() .expect("failed to create snowflake");

println!("{}", flake.id()); ```

check out the docs for more information

Features

State

there are additions that can be added. - using Atomics if possible (or sane). - other helper methods or structs if they are a common enough use case. - trying to get more performance so that the library is not the bottle neck - other things?

since the api is fairly minimal there probably wont be too much in terms of change but just as a precaution this will not have a major version until it is finalized (open to suggestions).

Contributions

fixes, improvements, or suggestions are welcome.