spawn_access_control/
lib.rs1pub mod access_control;
16pub mod access_manager;
17pub mod alert_analyzer;
18pub mod alert_ml;
19pub mod alert_storage;
20pub mod alert_system;
21pub mod audit;
22pub mod behavioral;
23pub mod error;
24pub mod geo_analyzer;
25pub mod metrics;
26pub mod ml_analyzer;
27pub mod ml_metrics;
28pub mod monitoring;
29pub mod security_analyzer;
30pub mod time_series_analyzer;
31pub mod model_explainer;
32pub mod model_optimizer;
33pub mod metrics_exporter;
34
35pub mod notification {
37 pub mod email;
38 pub mod slack;
39 pub use email::EmailNotificationHandler;
40 pub use slack::SlackNotificationHandler;
41}
42
43#[cfg(target_arch = "wasm32")]
45mod wasm;
46
47pub use chrono::{DateTime, Utc, Duration, Timelike, Datelike};
49pub use serde::{Serialize, Deserialize};
50pub use async_trait::async_trait;
51pub use std::hash::Hash;
52
53pub use crate::{
55 access_control::{AccessControl, Permission, Role, Resource},
56 access_manager::AccessManager,
57 alert_analyzer::{AlertAnalyzer, AlertPattern, PatternType},
58 alert_system::{AlertNotification, AlertSeverity, NotificationHandler, EscalationLevel},
59 monitoring::{ModelHealth, HealthStatus, AlertSeverity as MonitoringAlertSeverity},
60 security_analyzer::{SecurityAnalyzer, SecurityReport},
61};
62
63pub mod prelude {
65 pub use crate::{
66 AccessControl, Permission, Role, Resource,
67 AlertAnalyzer, AlertPattern, PatternType,
68 AlertNotification, AlertSeverity, EscalationLevel,
69 ModelHealth, HealthStatus,
70 SecurityReport,
71 };
72}
73
74pub use error::Error;
76pub type Result<T> = std::result::Result<T, Error>;
77
78#[derive(Debug, Clone, Serialize, Deserialize)]
80pub struct Config {
81 pub database_url: String,
82 #[serde(with = "duration_serde")]
83 pub cache_ttl: Duration,
84 pub max_retries: u32,
85 pub alert_threshold: f64,
86 pub enable_ml: bool,
87}
88
89mod duration_serde {
91 use chrono::Duration;
92 use serde::{Deserialize, Deserializer, Serialize, Serializer};
93
94 pub fn serialize<S>(duration: &Duration, serializer: S) -> Result<S::Ok, S::Error>
95 where
96 S: Serializer,
97 {
98 duration.num_seconds().serialize(serializer)
99 }
100
101 pub fn deserialize<'de, D>(deserializer: D) -> Result<Duration, D::Error>
102 where
103 D: Deserializer<'de>,
104 {
105 let seconds = i64::deserialize(deserializer)?;
106 Ok(Duration::seconds(seconds))
107 }
108}
109
110impl Default for Config {
111 fn default() -> Self {
112 Self {
113 database_url: "mongodb://localhost:27017".to_string(),
114 cache_ttl: Duration::minutes(30),
115 max_retries: 3,
116 alert_threshold: 0.8,
117 enable_ml: true,
118 }
119 }
120}
121
122impl From<serde_json::Error> for Error {
124 fn from(err: serde_json::Error) -> Self {
125 Error::Serialization(err.to_string())
126 }
127}
128
129impl From<std::io::Error> for Error {
130 fn from(err: std::io::Error) -> Self {
131 Error::Io(err.to_string())
132 }
133}
134
135impl From<Box<dyn std::error::Error>> for Error {
136 fn from(err: Box<dyn std::error::Error>) -> Self {
137 Error::Database(err.to_string())
138 }
139}
140
141pub use model_explainer::{SecurityImpactAnalysis, RiskFactor};