{"id":16527191,"url":"https://github.com/zignis/bit-roles","last_synced_at":"2025-06-23T10:35:45.411Z","repository":{"id":233170912,"uuid":"786198676","full_name":"zignis/bit-roles","owner":"zignis","description":"🔐 Granular role and permission management based on bit flags","archived":false,"fork":false,"pushed_at":"2024-06-08T14:06:34.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-03T19:59:07.129Z","etag":null,"topics":["macros-rust","permission-management","role-management"],"latest_commit_sha":null,"homepage":"https://docs.rs/bit_roles","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zignis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-04-13T18:04:37.000Z","updated_at":"2024-06-08T14:03:50.000Z","dependencies_parsed_at":"2025-03-27T16:43:47.549Z","dependency_job_id":"03450559-394c-4444-a24a-d741f9d3b16e","html_url":"https://github.com/zignis/bit-roles","commit_stats":null,"previous_names":["zignis/bit-roles"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/zignis/bit-roles","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zignis%2Fbit-roles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zignis%2Fbit-roles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zignis%2Fbit-roles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zignis%2Fbit-roles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zignis","download_url":"https://codeload.github.com/zignis/bit-roles/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zignis%2Fbit-roles/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261462674,"owners_count":23162010,"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":["macros-rust","permission-management","role-management"],"created_at":"2024-10-11T17:33:58.456Z","updated_at":"2025-06-23T10:35:40.395Z","avatar_url":"https://github.com/zignis.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bit Roles\n\n[![Latest Version](https://img.shields.io/crates/v/bit_roles.svg)](https://crates.io/crates/bit_roles)\n[![Rust Documentation](https://docs.rs/bit_roles/badge.svg)](https://docs.rs/bit_roles)\n\nThis crate enables you to implement granular role and permission management based on bit flags.\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth\u003e Using discrete fields \u003c/th\u003e\n        \u003cth\u003e Using bit roles \u003c/th\u003e\n    \u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```rust\n#[derive(Debug)]\nstruct User {\n    can_send_message: bool,\n    can_edit_message: bool\n}\n\nfn main() {\n    let user = User {\n        can_send_message: true,\n        can_edit_message: false\n    };\n}\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```rust\nuse bit_roles::BitRole;\n\n#[derive(Debug)]\nstruct User {\n    permissions: usize\n}\n\n#[derive(Debug, BitRole, Copy, Clone)]\nenum Permission {\n    None = 0,\n    SendMessage = 1,\n    EditMessage = 2,\n}\n\nfn main() {\n    let mut permissions = Permission::empty();\n    permissions.add_one(Permission::SendMessage);\n\n    let user = User {\n        permissions: permissions.get_value()\n    };\n}\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n## Getting started\n\nAdd `bit_roles` to your project:\n\n```shell\ncargo add bit_roles\n```\n\n## Usage\n\nYou can derive the `BitRole` trait for your role enum. It ensures compile-time validation for enum discriminants. Ensure\nyou specify a discriminant for every enum variant; it must be either zero or a power of two. Also, remember to derive\nthe `Copy` and `Clone` traits for your enum.\n\nIf you need a manager without compile-time checks, it's also exported as `BitRoleUnchecked` trait. This is useful if you\nwant to use raw integer values for roles or have a complex role enum definition. You will need to implement\nthe `Into\u003cusize\u003e` trait for your role enum, along with deriving the `Copy` and `Clone` traits for it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzignis%2Fbit-roles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzignis%2Fbit-roles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzignis%2Fbit-roles/lists"}