pub enum ExpirationPolicy {
Manual,
TimeToLive(Duration),
TimeToIdle(Duration),
}Expand description
The per-object expiration policy.
Controls automatic object cleanup. The policy is set by the client at upload
time via the x-sn-expiration header and persisted with
the object.
| Variant | Wire format | Behavior |
|---|---|---|
Manual | manual | No automatic expiration (default) |
TimeToLive | ttl:30s | Expires after a fixed duration from creation |
TimeToIdle | tti:1h | Expires after a duration of no access |
Durations use the wire format, which is written in days, hours, minutes,
and seconds (e.g. 30s, 5m, 1h, 7d, 400d 12h).
Important: Manual is the default and must remain so — persisted objects
without an explicit policy are deserialized as Manual.
Variants§
Manual
Manual expiration, meaning no automatic cleanup.
TimeToLive(Duration)
Time to live, with expiration after the specified duration.
TimeToIdle(Duration)
Time to idle, with expiration once the object has not been accessed within the specified duration.
Implementations§
Source§impl ExpirationPolicy
impl ExpirationPolicy
Sourcepub fn expires_in(&self) -> Option<Duration>
pub fn expires_in(&self) -> Option<Duration>
Returns the duration after which the object expires.
Sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
Returns true if this policy indicates time-based expiry.
Sourcepub fn check_tti_bump(
&self,
time_expires: Option<SystemTime>,
access_time: SystemTime,
) -> Option<SystemTime>
pub fn check_tti_bump( &self, time_expires: Option<SystemTime>, access_time: SystemTime, ) -> Option<SystemTime>
Checks whether a TTI deadline needs bumping given the current expiry and access time.
Returns Some(new_expire_at) when the current deadline is stale enough
to justify a write, None otherwise. The debounce window scales with the
TTI duration so short-TTI objects get bumped more frequently.
Trait Implementations§
Source§impl Clone for ExpirationPolicy
impl Clone for ExpirationPolicy
Source§fn clone(&self) -> ExpirationPolicy
fn clone(&self) -> ExpirationPolicy
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 ExpirationPolicy
impl Debug for ExpirationPolicy
Source§impl Default for ExpirationPolicy
impl Default for ExpirationPolicy
Source§fn default() -> ExpirationPolicy
fn default() -> ExpirationPolicy
Source§impl<'de> Deserialize<'de> for ExpirationPolicy
impl<'de> Deserialize<'de> for ExpirationPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ExpirationPolicy
impl Display for ExpirationPolicy
Source§impl FromStr for ExpirationPolicy
impl FromStr for ExpirationPolicy
Source§impl PartialEq for ExpirationPolicy
impl PartialEq for ExpirationPolicy
Source§fn eq(&self, other: &ExpirationPolicy) -> bool
fn eq(&self, other: &ExpirationPolicy) -> bool
self and other values to be equal, and is used by ==.