pub struct StorageRetentionPolicy { /* private fields */ }Expand description
Tick-based storage retention policy with built-in entry tracking.
Maintains a set of blocks (entries) and evaluates configurable rules against them. Rules are sorted by descending priority. Pinned entries are always kept regardless of rules.
Implementations§
Source§impl StorageRetentionPolicy
impl StorageRetentionPolicy
Sourcepub fn add_rule(&mut self, rule: TickRetentionRule)
pub fn add_rule(&mut self, rule: TickRetentionRule)
Adds a rule, maintaining descending priority order. If a rule with the same name already exists it is replaced.
Sourcepub fn remove_rule(&mut self, name: &str) -> bool
pub fn remove_rule(&mut self, name: &str) -> bool
Removes the rule with the given name.
Returns true if a rule was found and removed.
Sourcepub fn add_entry(&mut self, block_cid: &str, size_bytes: u64, created_tick: u64)
pub fn add_entry(&mut self, block_cid: &str, size_bytes: u64, created_tick: u64)
Registers a new block entry at the given creation tick.
Sourcepub fn pin(&mut self, block_cid: &str) -> bool
pub fn pin(&mut self, block_cid: &str) -> bool
Pins a block, protecting it from deletion/archival.
Returns true if the entry was found and pinned.
Sourcepub fn unpin(&mut self, block_cid: &str) -> bool
pub fn unpin(&mut self, block_cid: &str) -> bool
Unpins a block, allowing retention rules to apply.
Returns true if the entry was found and unpinned.
Sourcepub fn evaluate(&self, block_cid: &str) -> TickRetentionAction
pub fn evaluate(&self, block_cid: &str) -> TickRetentionAction
Evaluates retention rules against a single block.
Pinned blocks always return Keep. Rules are evaluated in descending
priority order; the first matching rule wins. If no rule matches,
the default is Keep.
Sourcepub fn enforce(&mut self) -> Vec<(String, TickRetentionAction)>
pub fn enforce(&mut self) -> Vec<(String, TickRetentionAction)>
Evaluates all entries and enforces the policy.
Entries marked for deletion are removed from the internal store.
Returns a list of (cid, action) pairs for entries that received
Archive or Delete actions.
Sourcepub fn access(&mut self, block_cid: &str)
pub fn access(&mut self, block_cid: &str)
Updates the last_accessed_tick of the given entry to the current tick.
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Returns the number of entries currently tracked.
Sourcepub fn total_size_bytes(&self) -> u64
pub fn total_size_bytes(&self) -> u64
Returns the total size in bytes of all tracked entries.
Sourcepub fn stats(&self) -> RetentionPolicyStats
pub fn stats(&self) -> RetentionPolicyStats
Returns aggregate statistics about this policy.
Sourcepub fn current_tick(&self) -> u64
pub fn current_tick(&self) -> u64
Returns the current tick value.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StorageRetentionPolicy
impl RefUnwindSafe for StorageRetentionPolicy
impl Send for StorageRetentionPolicy
impl Sync for StorageRetentionPolicy
impl Unpin for StorageRetentionPolicy
impl UnsafeUnpin for StorageRetentionPolicy
impl UnwindSafe for StorageRetentionPolicy
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> 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