Initial Implementation of ResourceGuard Macro

This commit is contained in:
2024-02-24 19:03:48 -03:00
parent ef43c102aa
commit 077f69778f
15 changed files with 102 additions and 40 deletions

8
utils/Cargo.toml Normal file
View File

@@ -0,0 +1,8 @@
[package]
name = "utils"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

24
utils/src/lib.rs Normal file
View File

@@ -0,0 +1,24 @@
pub enum ResourceType {
OPEN,
USER,
ADMIN,
}
impl ResourceType {
fn as_str(&self) -> &str {
match self {
ResourceType::OPEN => "OPEN",
ResourceType::USER => "USER",
ResourceType::ADMIN => "ADMIN",
}
}
fn from_str(s: &str) -> ResourceType {
match s {
"OPEN" => ResourceType::OPEN,
"USER" => ResourceType::USER,
"ADMIN" => ResourceType::ADMIN,
_ => panic!("Invalid resource type"),
}
}
}