pub struct ColdStorageManager { /* private fields */ }Expand description
Policy-driven manager that tracks blocks across four storage tiers and migrates them according to access recency.
Implementations§
Source§impl ColdStorageManager
impl ColdStorageManager
Sourcepub fn new(policy: TierPolicy) -> Self
pub fn new(policy: TierPolicy) -> Self
Create a new manager with the supplied tier policy.
Sourcepub fn register_block(&mut self, cid: &str, size: u64, now: u64)
pub fn register_block(&mut self, cid: &str, size: u64, now: u64)
Register a previously unknown block. If the CID is already known this
is a no-op — use access_block to refresh an existing entry.
Sourcepub fn access_block(&mut self, cid: &str, now: u64) -> bool
pub fn access_block(&mut self, cid: &str, now: u64) -> bool
Record an access to the block identified by cid.
Updates last_accessed and increments access_count.
Returns false when the CID is not tracked by this manager.
Sourcepub fn evaluate_migration(
&self,
block: &TieredBlock,
now: u64,
) -> Option<StorageTier>
pub fn evaluate_migration( &self, block: &TieredBlock, now: u64, ) -> Option<StorageTier>
Evaluate whether block should be migrated to a colder tier given the
current timestamp.
Returns Some(target_tier) when migration is warranted, None
otherwise.
Sourcepub fn migrate_block(
&mut self,
cid: &str,
target: StorageTier,
now: u64,
) -> bool
pub fn migrate_block( &mut self, cid: &str, target: StorageTier, now: u64, ) -> bool
Migrate a single block to target tier.
- Records
archived_atwhen entering Cold or Frozen. - Simulates a compression ratio (using the CID checksum as a
deterministic surrogate) when
compress_coldis set and the block enters Cold or Frozen.
Returns false when the CID is not tracked.
Sourcepub fn run_migration_pass(&mut self, now: u64) -> usize
pub fn run_migration_pass(&mut self, now: u64) -> usize
Scan every tracked block and migrate any that are eligible according to the current policy. Returns the number of blocks migrated.
Sourcepub fn blocks_in_tier(&self, tier: &StorageTier) -> Vec<&TieredBlock>
pub fn blocks_in_tier(&self, tier: &StorageTier) -> Vec<&TieredBlock>
Return references to all blocks currently in the specified tier.
Sourcepub fn get_block(&self, cid: &str) -> Option<&TieredBlock>
pub fn get_block(&self, cid: &str) -> Option<&TieredBlock>
Retrieve metadata for a single block by CID.
Sourcepub fn policy(&self) -> &TierPolicy
pub fn policy(&self) -> &TierPolicy
Return the active tier policy.
Sourcepub fn unfreeze(&mut self, cid: &str) -> bool
pub fn unfreeze(&mut self, cid: &str) -> bool
Move a Frozen block back to Cold.
This is the only supported “warming” operation. The block’s
archived_at timestamp is preserved. Returns false when the CID
is not tracked or is not currently Frozen.
Sourcepub fn stats(&self) -> &ColdStorageStats
pub fn stats(&self) -> &ColdStorageStats
Return a reference to the current statistics snapshot.
Note: stats are maintained incrementally; call rebuild_stats if
you suspect drift.
Sourcepub fn rebuild_stats(&mut self)
pub fn rebuild_stats(&mut self)
Recompute all statistics from scratch by iterating every tracked block.
Use this to correct any accumulator drift, e.g. after bulk operations.
Sourcepub fn remove_block(&mut self, cid: &str) -> bool
pub fn remove_block(&mut self, cid: &str) -> bool
Remove a block from tracking entirely.
Returns false when the CID was not found.
Auto Trait Implementations§
impl Freeze for ColdStorageManager
impl RefUnwindSafe for ColdStorageManager
impl Send for ColdStorageManager
impl Sync for ColdStorageManager
impl Unpin for ColdStorageManager
impl UnsafeUnpin for ColdStorageManager
impl UnwindSafe for ColdStorageManager
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