feat(backend): Phase 2.5 permission and share models
Some checks failed
Lint and Build / Lint (push) Has been cancelled
Lint and Build / Build (push) Has been cancelled
Lint and Build / Docker Build (push) Has been cancelled

This commit is contained in:
goose 2026-02-15 21:08:31 -03:00
parent 3eeef6d9c8
commit eb0e2cc4b5
7 changed files with 265 additions and 106 deletions

View file

@ -0,0 +1,33 @@
use serde::{Deserialize, Serialize};
use strum::{Display, EnumString};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Display, EnumString)]
#[serde(rename_all = "lowercase")]
#[strum(serialize_all = "lowercase")]
pub enum Permission {
Read,
Write,
Delete,
Share,
Admin,
}
impl Permission {
pub fn can_read(&self) -> bool {
matches!(self, Self::Read | Self::Admin)
}
pub fn can_write(&self) -> bool {
matches!(self, Self::Write | Self::Admin)
}
pub fn can_delete(&self) -> bool {
matches!(self, Self::Delete | Self::Admin)
}
pub fn can_share(&self) -> bool {
matches!(self, Self::Share | Self::Admin)
}
}
pub type Permissions = Vec<Permission>;