{"id":16800725,"url":"https://github.com/houseme/snowflake-rs","last_synced_at":"2025-03-17T03:31:09.845Z","repository":{"id":60791435,"uuid":"545146577","full_name":"houseme/snowflake-rs","owner":"houseme","description":"A simple to use rust package to generate or parse Twitter snowflake IDs,generate time sortable 64 bits unique ids for distributed systems (inspired from twitter snowflake)","archived":false,"fork":false,"pushed_at":"2024-10-16T05:26:10.000Z","size":74,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-27T17:17:53.881Z","etag":null,"topics":["generator","id","random","rust","snowflake","unique-id"],"latest_commit_sha":null,"homepage":"https://houseme.github.io/snowflake-rs/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/houseme.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":"houseme","issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://paypal.me/houseme"]}},"created_at":"2022-10-03T21:35:49.000Z","updated_at":"2024-10-16T05:24:39.000Z","dependencies_parsed_at":"2024-03-03T04:29:03.000Z","dependency_job_id":"d19db02c-8013-4665-9638-10793a83f67f","html_url":"https://github.com/houseme/snowflake-rs","commit_stats":{"total_commits":33,"total_committers":2,"mean_commits":16.5,"dds":0.1515151515151515,"last_synced_commit":"9039aa9f3af1bc96646df8bb8c8201319f907949"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houseme%2Fsnowflake-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houseme%2Fsnowflake-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houseme%2Fsnowflake-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houseme%2Fsnowflake-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/houseme","download_url":"https://codeload.github.com/houseme/snowflake-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243841203,"owners_count":20356443,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generator","id","random","rust","snowflake","unique-id"],"created_at":"2024-10-13T09:34:49.892Z","updated_at":"2025-03-17T03:31:09.576Z","avatar_url":"https://github.com/houseme.png","language":"Rust","funding_links":["https://liberapay.com/houseme","https://paypal.me/houseme"],"categories":[],"sub_categories":[],"readme":"# Snowflake-rs\n\nA simple to use rust package to generate or parse Twitter snowflake IDs, generate time sortable 64-bit unique ids for\ndistributed systems (inspired from twitter snowflake)\n\n[![Build](https://github.com/houseme/snowflake-rs/workflows/Build/badge.svg)](https://github.com/houseme/snowflake-rs/actions?query=workflow%3ABuild)\n[![crates.io](https://img.shields.io/crates/v/snowflake_me.svg)](https://crates.io/crates/snowflake_me)\n[![docs.rs](https://docs.rs/snowflake_me/badge.svg)](https://docs.rs/snowflake_me/)\n[![License](https://img.shields.io/crates/l/snowflake_me)](LICENSE-APACHE)\n\nA distributed unique ID generator inspired by [Twitter's Snowflake](https://blog.twitter.com/2010/announcing-snowflake).\n\nThis is a Rust implementation of the original [houseme/snowflake](https://github.com/houseme/snowflake), which is\nwritten in Go.\n\nA Snowflake ID is composed of\n\n- 39 bits for time in units of 10 msec\n- 8 bits for a sequence number\n- 8 bits for a data center id\n- 8 bits for a machine id\n\n## Install\n\nAdd the following to your `Cargo.toml`:\n\n```toml\n[dependencies]\nsnowflake_me = \"0.3\"\n```\n\n## Quickstart\n\n```rust\nuse snowflake_me::Snowflake;\n\nlet sf = Snowflake::new().unwrap();\nlet next_id = sf.next_id().unwrap();\nprintln!(\"{}\", next_id);\n```\n\n### Customize the start time\n\n```rust\nuse snowflake_me::Snowflake;\nuse chrono::prelude::*;\n\nlet sf = Snowflake::builder().start_time(Utc::now()).finalize().unwrap();\nlet next_id = sf.next_id().unwrap();\nprintln!(\"{}\", next_id);\n```\n\n### Customize the machine ID\n\n```rust \nuse snowflake_me::Snowflake;\n\nlet sf = Snowflake::builder().machine_id( \u0026 | | Ok(42)).finalize().unwrap();\nlet next_id = sf.next_id().unwrap();\nprintln!(\"{}\", next_id);\n``` \n\n### Customize the datacenter ID\n\n```rust\nuse snowflake_me::Snowflake;\n\nlet sf = Snowflake::builder().data_center_id( \u0026 | | Ok(42)).finalize().unwrap();\nlet next_id = sf.next_id().unwrap();\nprintln!(\"{}\", next_id);\n```\n\n### Resolve ID\n\n```rust\nuse snowflake_me::{decompose, Snowflake};\n\nlet sf = Snowflake::new().unwrap();\nlet next_id = sf.next_id().unwrap();\n\nlet parts = decompose(next_id);\nprintln!(\"timestamp: {}, machine_id: {}, sequence: {}, data_center_id:{}\", parts.time, parts.machine_id, parts.sequence, parts.data_center_id);\n```\n\n## Benchmarks\n\nRun them yourself with `cargo bench`.\n\n#### 1, Benchmarks were run on a MacBook Pro (16-inch, 2019) with a 2,4GHz i9 and 64 GB memory.\n\n```benchmark\ntest bench_decompose ... bench:         651 ns/iter (+/- 251)\ntest bench_new       ... bench:     795,722 ns/iter (+/- 371,556)\ntest bench_next_id   ... bench:      36,652 ns/iter (+/- 1,105)\n```\n\n#### 2, Benchmarks were run on a MacBook Pro (15-inch, 2017) with a 2,8GHz i7 and 16 GB memory.\n\n```benchmark\ntest bench_decompose ... bench:       1,066 ns/iter (+/- 132)\ntest bench_new       ... bench:     738,129 ns/iter (+/- 318,192)\ntest bench_next_id   ... bench:      37,390 ns/iter (+/- 499)\n```\n\n## License\n\nLicensed under either of\n\n* Apache License, Version 2.0, [LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0\n* MIT license [LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as\ndefined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhouseme%2Fsnowflake-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhouseme%2Fsnowflake-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhouseme%2Fsnowflake-rs/lists"}