mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-09 06:39:25 +00:00
33 lines
693 B
Rust
33 lines
693 B
Rust
use ecstore::error::{Error, Result};
|
|
use serde::{Deserialize, Serialize};
|
|
use strum::{EnumString, IntoStaticStr};
|
|
|
|
use crate::sys::Validator;
|
|
|
|
#[derive(Serialize, Clone, Deserialize, EnumString, IntoStaticStr, Default, Debug, PartialEq)]
|
|
#[serde(try_from = "&str", into = "&str")]
|
|
pub enum Effect {
|
|
#[default]
|
|
#[strum(serialize = "Allow")]
|
|
Allow,
|
|
#[strum(serialize = "Deny")]
|
|
Deny,
|
|
}
|
|
|
|
impl Effect {
|
|
pub fn is_allowed(&self, allowed: bool) -> bool {
|
|
if matches!(self, Self::Allow) {
|
|
return allowed;
|
|
}
|
|
|
|
!allowed
|
|
}
|
|
}
|
|
|
|
impl Validator for Effect {
|
|
type Error = Error;
|
|
fn is_valid(&self) -> Result<()> {
|
|
Ok(())
|
|
}
|
|
}
|