conduwuit/src/service/acl/data.rs

25 lines
692 B
Rust
Raw Normal View History

2023-12-24 11:03:02 +01:00
use serde::{Serialize, Deserialize};
use url::Host;
pub trait Data: Send + Sync {
/// check if given host exists in Acls, if so return it
fn check_acl(&self,host: &Host<String> ) -> crate::Result<Option<AclMode>>;
/// add a given Acl entry to the database
fn add_acl(&self, acl: AclDatabaseEntry) -> crate::Result<()>;
/// remove a given Acl entry from the database
fn remove_acl(&self,host: Host<String>) -> crate::Result<()>;
}
#[derive(Serialize,Deserialize, Debug, Clone, Copy)]
pub enum AclMode{
Block,
Allow
}
#[derive(Serialize,Deserialize, Debug, Clone)]
pub struct AclDatabaseEntry {
pub(crate) mode: AclMode,
pub(crate) hostname: Host
}