Skip to main content

RuleRegistry

Struct RuleRegistry 

Source
pub struct RuleRegistry { /* private fields */ }
Expand description

Hot-swappable rule registry.

Thread-safe: all public operations take &self and synchronize internally via RwLock.

Implementations§

Source§

impl RuleRegistry

Source

pub fn new( max_history_per_rule: usize, swap_backend: Arc<dyn RuleSwapBackend>, ) -> Self

Create a new registry with the given backend.

max_history_per_rule determines how many prior versions we keep available for rollback. When the limit is exceeded, the oldest version is evicted (FIFO).

Source

pub fn with_verifier(self, verifier: Arc<dyn SignatureVerifier>) -> Self

Attach a signature verifier. Rules without signatures are rejected once a verifier is set.

Source

pub fn rule_count(&self) -> usize

Number of rules currently registered.

Source

pub fn max_history(&self) -> usize

Configured history depth per rule.

Source

pub async fn register_rule( &self, rule: CompiledRule, device_compute_cap: &str, ) -> Result<RuleHandle, RuleError>

Register a rule for the first time (or register a new version of an existing rule without making it active).

On success, the new version has status RuleStatus::Registered if the rule already had an active version; otherwise it is immediately activated and returned with RuleStatus::Active.

Source

pub async fn reload_rule( &self, rule: CompiledRule, device_compute_cap: &str, ) -> Result<ReloadReport, RuleError>

Atomically hot-swap a new version of an existing rule.

Preconditions:

  • rule is already registered
  • proposed version strictly greater than current active version
  • validation passes (signature, compute cap, deps)

Postconditions:

Source

pub async fn rollback_rule( &self, rule_id: &str, to_version: u64, ) -> Result<ReloadReport, RuleError>

Roll back to a specific earlier version kept in history.

Unlike reload_rule, rollback marks the previously active version as RuleStatus::Rolledback (not Superseded) so auditors can tell the transition apart.

Source

pub fn list_rules(&self) -> Vec<RuleHandle>

List the active handle for every registered rule.

Source

pub fn get_rule(&self, rule_id: &str, version: u64) -> Option<CompiledRule>

Return a specific (rule_id, version) artifact if still in history.

Source

pub fn get_active(&self, rule_id: &str) -> Option<CompiledRule>

Return the currently active rule artifact, if any.

Source

pub fn history(&self, rule_id: &str) -> Vec<RuleHandle>

Full history for a rule (oldest first).

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to 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