{"id":20410908,"url":"https://github.com/mintlu8/strflags","last_synced_at":"2026-05-28T20:31:04.644Z","repository":{"id":195541610,"uuid":"693176792","full_name":"mintlu8/strflags","owner":"mintlu8","description":"A string-enum and string-flags with fixed variants that can also accept arbitrary data.","archived":false,"fork":false,"pushed_at":"2023-09-26T06:34:38.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-04T09:57:35.488Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mintlu8.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2023-09-18T13:57:17.000Z","updated_at":"2023-09-18T14:01:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"8a622cbb-d221-4438-ab3a-346eb308e654","html_url":"https://github.com/mintlu8/strflags","commit_stats":null,"previous_names":["mintlu8/strflags"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mintlu8/strflags","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintlu8%2Fstrflags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintlu8%2Fstrflags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintlu8%2Fstrflags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintlu8%2Fstrflags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mintlu8","download_url":"https://codeload.github.com/mintlu8/strflags/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintlu8%2Fstrflags/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33626136,"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-05-28T02:00:06.440Z","response_time":99,"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":[],"created_at":"2024-11-15T05:49:01.451Z","updated_at":"2026-05-28T20:31:04.609Z","avatar_url":"https://github.com/mintlu8.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# strflags\n\nA string-enum and string-flags with fixed variants that can also accept arbitrary data.\n\nThis is more extensible than traditional enums, bitflags or enumset,\nwhile being more ergonomic and more typo-resiliant than a set of strings like `HashSet\u003cString\u003e`.\n\n## Example\n\n```rust\nstr_flags! {\n    #[derive(PartialOrd)]\n    pub Color: [\n        Red,\n        Green,\n        DarkBlue,\n    ]\n}\n```\n\n### This Generates\n\n`pub struct Color(..)`\n\nAnd consts:\n\n* `pub const Red: Color = \"red\";`\n* `pub const Green: Color = \"green\";`\n* `pub const DarkBlue: Color = \"darkblue\";`\n\n### And auto implements\n\n* `Debug`, `Clone`, `Eq`, `Hash`\n* `Display`\n* `FromStr`\n* `Borrow\u003cstr\u003e`\n* `AsRef\u003cstr\u003e`\n* `PartialEq\u003cimpl AsRef\u003cstr\u003e\u003e`\n* `Into\u003cFlags\u003cSelf\u003e\u003e`\n* `BitOr\u003cOutput = Flags\u003cSelf\u003e\u003e`\n* `Serialize`, with the `serde` feature enabled\n* `Deserialize`, with the `serde` feature enabled\n\n### Flags\n\nYou can create a `Flags\u003cColor\u003e` like this.\n\n### `str_enum!()`\n\nuse the `str_enum!()` macro to opt out of flags related features.\n\n```rust\nlet flags = Color::Red | Color::Green | Color::new(\"Yellow\");\n```\n\n## Format\n\nWe stores all data in `flatlowercase`\nto avoid case mismatches and some typos.\n\n## Serialization and Deserialization\n\nWe use a string to serialize our \"string enums\".\n\ne.g. `\"red\"`\n\nWe use a csv like string to serialize our `Flags`\n\ne.g. `\"dog|cat|giraffe\"`\n\nThis ensures converting from enum to `Flags` does not break serialization formats.\n\n## The `debug` feature\n\nAllowing any string to be an enum variant is obviously prone to typos.\nWhen the debug feature is enabled, we performs a fuzzy string check\nevery time a comparison is made and emit a `warn!`\nthough the `log` crate\nif similar strings are found.\nThis is obviously slow so be careful when using this feature.\n\n## Warning\n\nCurrently we use [`EcoString`](https://docs.rs/ecow/latest/ecow/string/struct.EcoString.html)\nwhich can only inline 15 bytes. Having a larger compile time constant string\nis a ***runtime*** error if the constant is **USED**.\n\nA proc macro implementation in the future will address this issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmintlu8%2Fstrflags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmintlu8%2Fstrflags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmintlu8%2Fstrflags/lists"}