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<ExpirationPolicy, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ExpirationPolicy, <__D as Deserializer<'de>>::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 ==.Source§impl Serialize for ExpirationPolicy
impl Serialize for ExpirationPolicy
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for ExpirationPolicy
impl Eq for ExpirationPolicy
impl StructuralPartialEq for ExpirationPolicy
Auto Trait Implementations§
impl Freeze for ExpirationPolicy
impl RefUnwindSafe for ExpirationPolicy
impl Send for ExpirationPolicy
impl Sync for ExpirationPolicy
impl Unpin for ExpirationPolicy
impl UnsafeUnpin for ExpirationPolicy
impl UnwindSafe for ExpirationPolicy
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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