Skip to main content

PluginManager

Struct PluginManager 

Source
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

Source

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.

Source

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.

Source

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.

Source

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).

Source

pub fn plugin_count(&self) -> usize

Returns the number of currently loaded plugins.

Source

pub fn plugin_names(&self) -> Vec<&str>

Returns the names of all currently loaded plugins.

Source

pub fn is_enabled(&self) -> bool

Returns whether the plugin system is enabled.

Trait Implementations§

Source§

impl Debug for PluginManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more