#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum PermissionDecision {
Allow,
Deny,
Ask,
}
#[derive(Debug, Clone)]
pub struct PermissionVerdict {
pub decision: PermissionDecision,
pub reason: Option<String>,
}
impl PermissionVerdict {
pub const fn allow() -> Self {
Self {
decision: PermissionDecision::Allow,
reason: None,
}
}
pub const fn deny(reason: Option<String>) -> Self {
Self {
decision: PermissionDecision::Deny,
reason,
}
}
pub const fn ask(reason: Option<String>) -> Self {
Self {
decision: PermissionDecision::Ask,
reason,
}
}
}
impl PartialEq for PermissionVerdict {
fn eq(&self, other: &Self) -> bool {
self.decision == other.decision && self.reason == other.reason
}
}
impl Eq for PermissionVerdict {}
impl PermissionVerdict {
pub fn decision_eq(&self, other: &Self) -> bool {
self.decision == other.decision
}
}