#[cfg(feature = "plugin")]
pub mod loader;
#[cfg(feature = "plugin")]
pub use manager::PluginManager;
pub mod manager;
use crate::cipher::provider::SymmetricCipher;
use crate::error::Result;
use crate::types::Algorithm;
use lazy_static::lazy_static;
use std::any::Any;
use std::sync::Arc;
lazy_static! {
pub static ref PLUGIN_MANAGER: PluginManager = PluginManager::new();
}
#[cfg(feature = "plugin")]
pub trait Plugin: Send + Sync {
fn name(&self) -> &str;
fn version(&self) -> &str;
fn initialize(&mut self) -> Result<()>;
fn shutdown(&mut self) -> Result<()>;
fn health_check(&self) -> Result<bool>;
fn as_any(&self) -> &dyn Any;
}
#[cfg(feature = "plugin")]
pub trait CipherPlugin: Plugin {
fn as_symmetric_cipher(&self) -> Arc<dyn SymmetricCipher>;
fn supported_algorithms(&self) -> Vec<Algorithm>;
}
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg(feature = "plugin")]
pub struct PluginMetadata {
pub name: String,
pub version: String,
pub author: String,
pub description: String,
pub dependencies: Vec<String>,
pub checksum: String,
}
#[derive(Debug)]
#[cfg(feature = "plugin")]
pub struct PluginLoadError {
pub plugin_name: String,
pub reason: String,
pub recoverable: bool,
}
impl std::fmt::Display for PluginLoadError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"Plugin load error: {} - {}",
self.plugin_name, self.reason
)
}
}
impl std::error::Error for PluginLoadError {}