spawn-access-control 0.1.12

A Rust library for access control management with WebAssembly support, including role-based access control (RBAC), permissions, and audit logging.
Documentation
//! # Spawn Access Control
//! 
//! Gelişmiş güvenlik ve erişim kontrolü için Rust tabanlı kütüphane.
//! 
//! ## Özellikler
//! 
//! - Role-based access control (RBAC)
//! - Davranışsal analiz ve anomali tespiti
//! - Makine öğrenimi destekli güvenlik
//! - Gerçek zamanlı alert sistemi
//! - Zaman serisi analizi ve tahminleme
//! - WebAssembly desteği

// Temel modüller
pub mod access_control;
pub mod access_manager;
pub mod alert_analyzer;
pub mod alert_ml;
pub mod alert_storage;
pub mod alert_system;
pub mod audit;
pub mod behavioral;
pub mod error;
pub mod geo_analyzer;
pub mod metrics;
pub mod ml_analyzer;
pub mod ml_metrics;
pub mod monitoring;
pub mod security_analyzer;
pub mod time_series_analyzer;
pub mod model_explainer;
pub mod model_optimizer;
pub mod metrics_exporter;

// Notification modülü
pub mod notification {
    pub mod email;
    pub mod slack;
    pub use email::EmailNotificationHandler;
    pub use slack::SlackNotificationHandler;
}

// WASM desteği
#[cfg(target_arch = "wasm32")]
mod wasm;

// Temel trait'ler ve tipler
pub use chrono::{DateTime, Utc, Duration, Timelike, Datelike};
pub use serde::{Serialize, Deserialize};
pub use async_trait::async_trait;
pub use std::hash::Hash;

// Re-exports
pub use crate::{
    access_control::{AccessControl, Permission, Role, Resource},
    access_manager::AccessManager,
    alert_analyzer::{AlertAnalyzer, AlertPattern, PatternType},
    alert_system::{AlertNotification, AlertSeverity, NotificationHandler, EscalationLevel},
    monitoring::{ModelHealth, HealthStatus, AlertSeverity as MonitoringAlertSeverity},
    security_analyzer::{SecurityAnalyzer, SecurityReport},
};

// Prelude modülü
pub mod prelude {
    pub use crate::{
        AccessControl, Permission, Role, Resource,
        AlertAnalyzer, AlertPattern, PatternType,
        AlertNotification, AlertSeverity, EscalationLevel,
        ModelHealth, HealthStatus,
        SecurityReport,
    };
}

// Error tipi
pub use error::Error;
pub type Result<T> = std::result::Result<T, Error>;

// Genel konfigürasyon yapısı
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Config {
    pub database_url: String,
    #[serde(with = "duration_serde")]
    pub cache_ttl: Duration,
    pub max_retries: u32,
    pub alert_threshold: f64,
    pub enable_ml: bool,
}

// Duration serileştirme modülü
mod duration_serde {
    use chrono::Duration;
    use serde::{Deserialize, Deserializer, Serialize, Serializer};

    pub fn serialize<S>(duration: &Duration, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: Serializer,
    {
        duration.num_seconds().serialize(serializer)
    }

    pub fn deserialize<'de, D>(deserializer: D) -> Result<Duration, D::Error>
    where
        D: Deserializer<'de>,
    {
        let seconds = i64::deserialize(deserializer)?;
        Ok(Duration::seconds(seconds))
    }
}

impl Default for Config {
    fn default() -> Self {
        Self {
            database_url: "mongodb://localhost:27017".to_string(),
            cache_ttl: Duration::minutes(30),
            max_retries: 3,
            alert_threshold: 0.8,
            enable_ml: true,
        }
    }
}

// Error dönüşümleri için
impl From<serde_json::Error> for Error {
    fn from(err: serde_json::Error) -> Self {
        Error::Serialization(err.to_string())
    }
}

impl From<std::io::Error> for Error {
    fn from(err: std::io::Error) -> Self {
        Error::Io(err.to_string())
    }
}

impl From<Box<dyn std::error::Error>> for Error {
    fn from(err: Box<dyn std::error::Error>) -> Self {
        Error::Database(err.to_string())
    }
}

// Re-export if needed
pub use model_explainer::{SecurityImpactAnalysis, RiskFactor};