Crates.io | rusty-snowflake |
lib.rs | rusty-snowflake |
version | 0.2.0 |
source | src |
created_at | 2023-05-20 02:59:10.244565 |
updated_at | 2023-05-22 01:22:18.827925 |
description | A library for generating and parsing Snowflake IDs |
homepage | |
repository | |
max_upload_size | |
id | 869188 |
size | 19,118 |
This library is a Snowflake ID generator and parser written entirely in Rust.
Add the following dependency to your Cargo.toml
file:
[dependencies]
rusty-snowflake = "0.2.0"
Or run the following in your project directory
cargo add rusty-snowflake
use rusty_snowflake::SnowflakeGenerator;
fn main() {
// Create a new snowflake generator with custom worker ID of 123
let mut generator = SnowflakeGenerator::new(123);
// Generate a new snowflake ID
let snowflake = generator.next();
println!("Generated snowflake id: {}", snowflake);
// Parse the snowflake ID
let parsed_snowflake = Snowflake::parse(snowflake.to_id());
println!("Parsed snowflake: {:?}", parsed_snowflake);
}
Contributions and feedback are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.
This project is licensed under the MIT License.