Snowflaked
A crate for creating and working with snowflake ids.
Usage
Add snowflaked
to your Cargo.toml
:
= "1.0.0"
This crate provides APIs for generating new snowflake ids and defining custom snowflake types.
Snowflake Generation
Use the Generator
type to create new snowflake ids:
use Generator;
let mut generator = new;
let id: u64 = generator.generate;
Or use the thread-safe sync::Generator
type (requires the optional sync
feature):
use Generator;
static GENERATOR: Generator = new;
Using custom snowflake types
Custom snowflake types can be defined with the Snowflake
trait. This trait is currently
implemented for u64
and i64
and can be used to define your custom types:
use Snowflake;
;
License
Licensed under either
- MIT License or
- Apache License, Version 2.0 at your option.