pub struct StorageRetentionPolicyEngine {
pub rules: Vec<RetentionRule>,
}Expand description
Engine that evaluates storage retention policies against block records.
Rules are maintained in descending priority order so that the highest-priority
rule is always evaluated first. Pinned blocks bypass all rules and always receive
a Keep decision.
Fields§
§rules: Vec<RetentionRule>Active rules, sorted in descending priority order.
Implementations§
Source§impl StorageRetentionPolicyEngine
impl StorageRetentionPolicyEngine
Sourcepub fn add_rule(&mut self, rule: RetentionRule)
pub fn add_rule(&mut self, rule: RetentionRule)
Adds a rule while maintaining descending priority order.
If two rules share the same priority, the newly inserted rule is placed after all existing rules with the same priority (stable ordering).
Sourcepub fn remove_rule(&mut self, rule_id: u64) -> bool
pub fn remove_rule(&mut self, rule_id: u64) -> bool
Removes the rule with the given rule_id.
Returns true if a rule was found and removed, false otherwise.
Sourcepub fn evaluate(&self, block: &BlockRecord, now_secs: u64) -> PolicyDecision
pub fn evaluate(&self, block: &BlockRecord, now_secs: u64) -> PolicyDecision
Evaluates retention policy rules against a single block.
Pinned blocks always receive RetentionAction::Keep with no matched rule.
Otherwise, rules are checked in descending priority order; the first rule
whose conditions all hold wins. If no rule matches, the default
RetentionAction::Keep is returned with matched_rule_id = None.
Sourcepub fn evaluate_all(
&self,
blocks: &[BlockRecord],
now_secs: u64,
) -> Vec<PolicyDecision>
pub fn evaluate_all( &self, blocks: &[BlockRecord], now_secs: u64, ) -> Vec<PolicyDecision>
Evaluates retention policy rules against every block in blocks.
Sourcepub fn stats(&self, decisions: &[PolicyDecision]) -> RetentionStats
pub fn stats(&self, decisions: &[PolicyDecision]) -> RetentionStats
Computes aggregate statistics from a slice of policy decisions.
Trait Implementations§
Source§impl Clone for StorageRetentionPolicyEngine
impl Clone for StorageRetentionPolicyEngine
Source§fn clone(&self) -> StorageRetentionPolicyEngine
fn clone(&self) -> StorageRetentionPolicyEngine
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StorageRetentionPolicyEngine
impl Debug for StorageRetentionPolicyEngine
Auto Trait Implementations§
impl Freeze for StorageRetentionPolicyEngine
impl RefUnwindSafe for StorageRetentionPolicyEngine
impl Send for StorageRetentionPolicyEngine
impl Sync for StorageRetentionPolicyEngine
impl Unpin for StorageRetentionPolicyEngine
impl UnsafeUnpin for StorageRetentionPolicyEngine
impl UnwindSafe for StorageRetentionPolicyEngine
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more