pub struct PluginManager { /* private fields */ }Expand description
Manages the lifecycle and evaluation of Wasm policy plugins.
§Fail-closed semantics
If any plugin errors during evaluation, the manager treats the result as a deny with the error description as the reason. This ensures that plugin failures never silently allow actions.
Implementations§
Source§impl PluginManager
impl PluginManager
Sourcepub fn new(config: PluginManagerConfig) -> Result<Self, PluginError>
pub fn new(config: PluginManagerConfig) -> Result<Self, PluginError>
Create a new plugin manager with the given configuration.
The configuration is validated before the manager is created.
Sourcepub fn load_plugin(
&mut self,
config: PluginConfig,
instance: Box<dyn PolicyPlugin>,
) -> Result<(), PluginError>
pub fn load_plugin( &mut self, config: PluginConfig, instance: Box<dyn PolicyPlugin>, ) -> Result<(), PluginError>
Load a plugin into the manager.
The plugin configuration is validated, and the plugin is instantiated
using the provided PolicyPlugin implementation.
§Errors
Returns PluginError::MaxPluginsExceeded if the manager is full,
PluginError::DuplicatePlugin if a plugin with the same name exists,
or PluginError::ConfigValidation if the config is invalid.
Sourcepub fn evaluate_all(&self, action: &Action) -> Vec<(String, PluginVerdict)>
pub fn evaluate_all(&self, action: &Action) -> Vec<(String, PluginVerdict)>
Evaluate all loaded plugins against the given action.
Returns a vector of (plugin_name, verdict) tuples. Plugin errors
are converted to deny verdicts (fail-closed).
If the plugin system is disabled or no plugins are loaded, returns an empty vector.
Sourcepub fn reload_plugins(
&mut self,
configs_and_instances: Vec<(PluginConfig, Box<dyn PolicyPlugin>)>,
) -> Result<(), PluginError>
pub fn reload_plugins( &mut self, configs_and_instances: Vec<(PluginConfig, Box<dyn PolicyPlugin>)>, ) -> Result<(), PluginError>
Replace all loaded plugins with a new set.
Validates each configuration before loading. If any validation fails, no plugins are replaced (atomic swap).
Sourcepub fn plugin_count(&self) -> usize
pub fn plugin_count(&self) -> usize
Returns the number of currently loaded plugins.
Sourcepub fn plugin_names(&self) -> Vec<&str>
pub fn plugin_names(&self) -> Vec<&str>
Returns the names of all currently loaded plugins.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns whether the plugin system is enabled.