{"id":16542592,"url":"https://github.com/ycd/sarmio","last_synced_at":"2025-10-28T15:30:55.538Z","repository":{"id":57666271,"uuid":"328036571","full_name":"ycd/sarmio","owner":"ycd","description":"📇 sarmio, A distributed unique ID generator inspired by Snowflake","archived":false,"fork":false,"pushed_at":"2021-01-09T23:51:14.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-05T06:49:00.587Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/ycd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-AL","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-08T23:41:54.000Z","updated_at":"2021-01-17T01:56:48.000Z","dependencies_parsed_at":"2022-09-26T20:31:42.799Z","dependency_job_id":null,"html_url":"https://github.com/ycd/sarmio","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ycd%2Fsarmio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ycd%2Fsarmio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ycd%2Fsarmio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ycd%2Fsarmio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ycd","download_url":"https://codeload.github.com/ycd/sarmio/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238672025,"owners_count":19511197,"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":[],"created_at":"2024-10-11T18:58:01.951Z","updated_at":"2025-10-28T15:30:55.228Z","avatar_url":"https://github.com/ycd.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sarmio\n\n### Distributed unique ID generator, inspired by [Twitter's snowflake](https://blog.twitter.com/engineering/en_us/a/2010/announcing-snowflake.html).\n\n\nSarmio creates a unique ID that is between the range of `0 \u003e n \u003e (2 ^ 64) -1`, also known as unsigned 64 bit integer.\n\n\n## Usage\n\nFirst of all, add `sarmio` as a dependency to your `cargo.toml`.\n\n```toml\n[dependencies]\nsarmio = \"0.1\"\n```\n\n\n\n## Example\n\n```rust\nfn main() {\n    // Create new Sarmio instance with a machine-id of 255.\n    let mut sarmio_one = sarmio::Sarmio::new(255);\n    let mut sarmio_two = sarmio::Sarmio::new(555);\n    // Sarmio implements Iterator\n    // Which means you can iterate over it to create new IDs.\n    let id1 = match sarmio_one.next_id() {\n        Some(s) =\u003e s,\n        None =\u003e 0,\n    };\n\n    let id2 = match sarmio_two.next_id() {\n        Some(s) =\u003e s,\n        None =\u003e 0,\n    };\n\n    // Or create a new  with next_id() syntax.\n\n    // Decompose it, get the values like\n    // Unix time in that moment, machine id\n    // and the Unique ID.\n    let id1_decomposed = sarmio::decompose(id1);\n    let id2_decomposed = sarmio::decompose(id2);\n\n    println!(\"{:?}\", id1_decomposed); // ID { id: 27015264398737663, machine_id: 255, time: 1610235238 }\n    println!(\"{:?}\", id2_decomposed); // ID { id: 27015264398737963, machine_id: 555, time: 1610235238 }\n\n    // Check which ID is older.\n    let is_older = id2_decomposed.older(\u0026id1_decomposed);\n\n    println!(\"{:?}\", is_older); // false\n\n    // Check whether the ID's are created in the same machine.\n    let same_machine = id2_decomposed.same_machine(\u0026id1_decomposed);\n\n    println!(\"{:?}\", same_machine) // false\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fycd%2Fsarmio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fycd%2Fsarmio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fycd%2Fsarmio/lists"}