{"id":20811358,"url":"https://github.com/ciffelia/nid","last_synced_at":"2026-06-10T02:00:55.854Z","repository":{"id":231068181,"uuid":"780821446","full_name":"ciffelia/nid","owner":"ciffelia","description":"Rust crate to generate and parse Nano IDs","archived":false,"fork":false,"pushed_at":"2026-06-09T20:03:47.000Z","size":69,"stargazers_count":9,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-06-09T20:08:59.465Z","etag":null,"topics":["id","nano","nanoid","unique","uuid"],"latest_commit_sha":null,"homepage":"https://docs.rs/nid","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/ciffelia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-04-02T08:16:19.000Z","updated_at":"2026-06-09T20:03:52.000Z","dependencies_parsed_at":"2025-05-07T09:46:42.848Z","dependency_job_id":null,"html_url":"https://github.com/ciffelia/nid","commit_stats":null,"previous_names":["ciffelia/nid"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/ciffelia/nid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ciffelia%2Fnid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ciffelia%2Fnid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ciffelia%2Fnid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ciffelia%2Fnid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ciffelia","download_url":"https://codeload.github.com/ciffelia/nid/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ciffelia%2Fnid/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34133404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["id","nano","nanoid","unique","uuid"],"created_at":"2024-11-17T20:40:37.024Z","updated_at":"2026-06-10T02:00:55.848Z","avatar_url":"https://github.com/ciffelia.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nid\n\n[![CI status][ci badge]][ci link]\n[![crates.io][crates.io badge]][crates.io link]\n[![docs][docs badge]][docs link]\n[![Apache 2.0 or MIT Licenses][license badge]][license link]\n\nGenerate and parse Nano IDs.\n\nNano ID is a small, secure, URL-friendly, unique string ID.\nHere's an example of a Nano ID:\n\n```\nqjH-6uGrFy0QgNJtUh0_c\n```\n\nThis crate is a Rust implementation of the original [Nano ID](https://github.com/ai/nanoid) library written in JavaScript.\nPlease refer to the original library for the detailed explanation of Nano ID.\n\n## Getting started\n\nAdd the following to your `Cargo.toml`:\n\n```toml\n[dependencies]\nnid = \"5.0.0\"\n```\n\nWhen you want a new Nano ID, you can generate one using the [`Nanoid::new`] method.\n\n```rust\nuse nid::Nanoid;\nlet id: Nanoid = Nanoid::new();\n```\n\nYou can parse a string into a Nano ID using [`Nanoid::try_from_str`], [`std::str::FromStr`] or [`TryFrom\u003cString\u003e`].\n\n```rust\nuse nid::Nanoid;\nlet id: Nanoid = Nanoid::try_from_str(\"K8N4Q7MNmeHJ-OHHoVDcz\")?;\nlet id: Nanoid = \"3hYR3muA_xvjMrrrqFWxF\".parse()?;\nlet id: Nanoid = \"iH26rJ8CpRz-gfIh7TSRu\".to_string().try_into()?;\n```\n\nIf the Nano ID string is constant, you can also use the [`nanoid`] macro to parse it at compile time.\n\n```rust\nuse nid::{nanoid, Nanoid};\nlet id = nanoid!(\"ClCrhcvy5kviH5ZozARfi\");\nconst ID: Nanoid = nanoid!(\"9vZZWqFI_rTou3Mutq1LH\");\n```\n\nThe length of the Nano ID is 21 by default. You can change it by specifying the generic parameter.\n\n```rust\nuse nid::Nanoid;\nlet id: Nanoid\u003c10\u003e = \"j1-SOTHHxi\".parse()?;\n```\n\nYou can also use a different alphabet. The list of available alphabets is in the [`alphabet`] module.\n\n```rust\nuse nid::{alphabet::Base62Alphabet, Nanoid};\nlet id: Nanoid\u003c10, Base62Alphabet\u003e = Nanoid::new();\n```\n\n## Examples\n\n```rust\nuse nid::{alphabet::Base62Alphabet, Nanoid};\n\n// Generate a new Nano ID and print it.\nlet id: Nanoid = Nanoid::new();\nprintln!(\"{}\", id);\n\n// Parse a string into a Nano ID and convert it back to a string.\nlet id: Nanoid = \"abcdefg1234567UVWXYZ_\".parse()?;\nlet s = id.to_string();\n\n// Parse a string into a Nano ID with a different length and alphabet.\nlet id: Nanoid\u003c9, Base62Alphabet\u003e = \"abc123XYZ\".parse()?;\n```\n\n## Features\n\n- `serde`: Add support for serialization and deserialization of [`Nanoid`]. Implement [`serde::Serialize`] and [`serde::Deserialize`] for [`Nanoid`].\n- `zeroize`: Add support for zeroizing the memory of [`Nanoid`]. Implement [`zeroize::Zeroize`] for [`Nanoid`].\n\n## Comparison with other implementations of Nano ID\n\n[`nanoid`](https://docs.rs/nanoid) and [`nano-id`](https://docs.rs/nano-id) are other implementations of Nano ID in Rust.\nThe main difference between `nid` and the other implementations is that `nid` has [`Nanoid`] type to represent Nano IDs.\nThis type provides a safe way to generate and parse Nano IDs.\nThis is similar to [`uuid`](https://docs.rs/uuid) crate, which provides [`Uuid`](https://docs.rs/uuid/latest/uuid/struct.Uuid.html) type to represent UUIDs.\n\n[`Nanoid::new`]: https://docs.rs/nid/latest/nid/struct.Nanoid.html#method.new\n[`Nanoid::try_from_str`]: https://docs.rs/nid/latest/nid/struct.Nanoid.html#method.try_from_str\n[`std::str::FromStr`]: https://doc.rust-lang.org/std/str/trait.FromStr.html\n[`TryFrom\u003cString\u003e`]: https://doc.rust-lang.org/std/convert/trait.TryFrom.html\n[`nanoid`]: https://docs.rs/nid/latest/nid/macro.nanoid.html\n[`alphabet`]: https://docs.rs/nid/latest/nid/alphabet/index.html\n[`Nanoid`]: https://docs.rs/nid/latest/nid/struct.Nanoid.html\n[`serde::Serialize`]: https://docs.rs/serde/latest/serde/ser/trait.Serialize.html\n[`serde::Deserialize`]: https://docs.rs/serde/latest/serde/de/trait.Deserialize.html\n[`zeroize::Zeroize`]: https://docs.rs/zeroize/latest/zeroize/trait.Zeroize.html\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 defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n\n[ci badge]: https://github.com/ciffelia/nid/actions/workflows/ci.yaml/badge.svg\n[ci link]: https://github.com/ciffelia/nid/actions/workflows/ci.yaml\n\n[crates.io badge]: https://img.shields.io/crates/v/nid?logo=rust\n[crates.io link]: https://crates.io/crates/nid\n\n[docs badge]: https://img.shields.io/badge/docs-online-teal\n[docs link]: https://docs.rs/nid\n\n[license badge]: https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue\n[license link]: #license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fciffelia%2Fnid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fciffelia%2Fnid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fciffelia%2Fnid/lists"}