pub struct ObjectLockManager { /* private fields */ }Expand description
Top-level manager. Owns per-(bucket, key) lock state and per-bucket
default configuration. All read / write operations go through RwLock
for thread safety; clones are cheap (Arc<ObjectLockManager> is the
expected handle shape).
Implementations§
Source§impl ObjectLockManager
impl ObjectLockManager
Sourcepub fn set(&self, bucket: &str, key: &str, state: ObjectLockState)
pub fn set(&self, bucket: &str, key: &str, state: ObjectLockState)
Replace (or create) the lock state for (bucket, key). service.rs’s
put_object_retention handler calls this directly after validating
the immutability rules (Compliance is one-way; once set, mode cannot
be downgraded and retain-until cannot be shortened — the caller
validates, this method just persists).
Sourcepub fn get(&self, bucket: &str, key: &str) -> Option<ObjectLockState>
pub fn get(&self, bucket: &str, key: &str) -> Option<ObjectLockState>
Return a clone of the current state for (bucket, key), if any.
Sourcepub fn set_legal_hold(&self, bucket: &str, key: &str, on: bool)
pub fn set_legal_hold(&self, bucket: &str, key: &str, on: bool)
Toggle the legal-hold flag on (bucket, key). Creates a default-empty
state if no entry exists yet (legal hold is allowed even without
retention).
Sourcepub fn set_bucket_default(&self, bucket: &str, default: BucketObjectLockDefault)
pub fn set_bucket_default(&self, bucket: &str, default: BucketObjectLockDefault)
Install (or replace) the bucket-default retention config. New PUTs to
this bucket without explicit retention pick this up via
Self::apply_default_on_put.
Sourcepub fn bucket_default(&self, bucket: &str) -> Option<BucketObjectLockDefault>
pub fn bucket_default(&self, bucket: &str) -> Option<BucketObjectLockDefault>
Look up the bucket-default retention config, if any.
Sourcepub fn apply_default_on_put(&self, bucket: &str, key: &str, now: DateTime<Utc>)
pub fn apply_default_on_put(&self, bucket: &str, key: &str, now: DateTime<Utc>)
On PUT: when the bucket has a default config and no per-object state
already exists for this key, materialise a fresh state with
retain_until = now + retention_days. Existing state (e.g. an
earlier explicit put_object_retention) is left unchanged so we
don’t accidentally re-arm a cleared retention on overwrite.
Sourcepub fn clear(&self, bucket: &str, key: &str)
pub fn clear(&self, bucket: &str, key: &str)
Drop any lock state attached to (bucket, key). Called by
service.rs after a successful (= permitted) physical delete so the
freed key can be re-armed by a future PUT under the bucket default.