# Bit Roles [![Latest Version](https://img.shields.io/crates/v/bit_roles.svg)](https://crates.io/crates/bit_roles) [![Rust Documentation](https://docs.rs/bit_roles/badge.svg)](https://docs.rs/bit_roles) This crate enables you to implement granular role and permission management based on bit flags.
Using discrete fields | Using bit roles |
---|---|
```rust #[derive(Debug)] struct User { can_send_message: bool, can_edit_message: bool } fn main() { let user = User { can_send_message: true, can_edit_message: false }; } ``` | ```rust use bit_roles::BitRole; #[derive(Debug)] struct User { permissions: usize } #[derive(Debug, BitRole, Copy, Clone)] enum Permission { None = 0, SendMessage = 1, EditMessage = 2, } fn main() { let mut permissions = Permission::empty(); permissions.add_one(Permission::SendMessage); let user = User { permissions: permissions.get_value() }; } ``` |