Initial Implementation of ResourceGuard Macro
This commit is contained in:
8
utils/Cargo.toml
Normal file
8
utils/Cargo.toml
Normal 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
24
utils/src/lib.rs
Normal 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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user