use std::sync::Arc;
use crate::{GateDecision, GateError, GateRequest};
pub trait Gate: Send + Sync + std::fmt::Debug {
fn check(&self, req: &GateRequest) -> Result<GateDecision, GateError>;
fn impl_name(&self) -> &'static str {
std::any::type_name::<Self>()
}
}
pub type GateRef = Arc<dyn Gate>;
#[derive(Clone, Debug, Default)]
pub struct AllowAllGate;
impl Gate for AllowAllGate {
fn check(&self, _req: &GateRequest) -> Result<GateDecision, GateError> {
Ok(GateDecision::allow())
}
fn impl_name(&self) -> &'static str {
"AllowAllGate"
}
}