AppFlowy-Cloud/libs/access-control/src/entity.rs

25 lines
583 B
Rust

/// Represents the object type that is stored in the access control policy.
#[derive(Debug)]
pub enum ObjectType<'id> {
/// Stored as `workspace::<uuid>`
Workspace(&'id str),
/// Stored as `collab::<uuid>`
Collab(&'id str),
}
impl ObjectType<'_> {
pub fn policy_object(&self) -> String {
match self {
ObjectType::Collab(s) => format!("collab::{}", s),
ObjectType::Workspace(s) => format!("workspace::{}", s),
}
}
pub fn object_id(&self) -> &str {
match self {
ObjectType::Collab(s) => s,
ObjectType::Workspace(s) => s,
}
}
}