#[non_exhaustive]pub struct MediaRetentionPolicy {
pub max_cache_size: Option<u64>,
pub max_file_size: Option<u64>,
pub last_access_expiry: Option<Duration>,
pub cleanup_frequency: Option<Duration>,
}
Expand description
The retention policy for media content used by the EventCacheStore
.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.max_cache_size: Option<u64>
The maximum authorized size of the overall media cache, in bytes.
The cache size is defined as the sum of the sizes of all the (possibly encrypted) media contents in the cache, excluding any metadata associated with them.
If this is set and the cache size is bigger than this value, the oldest media contents in the cache will be removed during a cleanup until the cache size is below this threshold.
Note that it is possible for the cache size to temporarily exceed this value between two cleanups.
Defaults to 400 MiB.
max_file_size: Option<u64>
The maximum authorized size of a single media content, in bytes.
The size of a media content is the size taken by the content in the database, after it was possibly encrypted, so it might differ from the initial size of the content.
The maximum authorized size of a single media content is actually the
lowest value between max_cache_size
and max_file_size
.
If it is set, media content bigger than the maximum size will not be cached. If the maximum size changed after media content that exceeds the new value was cached, the corresponding content will be removed during a cleanup.
Defaults to 20 MiB.
last_access_expiry: Option<Duration>
The duration after which unaccessed media content is considered expired.
If this is set, media content whose last access is older than this duration will be removed from the media cache during a cleanup.
Defaults to 60 days.
cleanup_frequency: Option<Duration>
The duration between two automatic media cache cleanups.
If this is set, a cleanup will be triggered after the given duration
is elapsed, at the next call to the media cache API. If this is set to
zero, each call to the media cache API will trigger a cleanup. If this
is None
, cleanups will only occur if they are triggered manually.
Defaults to running cleanups daily.
Implementations§
Source§impl MediaRetentionPolicy
impl MediaRetentionPolicy
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a MediaRetentionPolicy
with the default values.
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Create an empty MediaRetentionPolicy
.
This means that all media will be cached and cleanups have no effect.
Sourcepub fn with_max_cache_size(self, size: Option<u64>) -> Self
pub fn with_max_cache_size(self, size: Option<u64>) -> Self
Set the maximum authorized size of the overall media cache, in bytes.
Sourcepub fn with_max_file_size(self, size: Option<u64>) -> Self
pub fn with_max_file_size(self, size: Option<u64>) -> Self
Set the maximum authorized size of a single media content, in bytes.
Sourcepub fn with_last_access_expiry(self, duration: Option<Duration>) -> Self
pub fn with_last_access_expiry(self, duration: Option<Duration>) -> Self
Set the duration before which unaccessed media content is considered expired.
Sourcepub fn with_cleanup_frequency(self, duration: Option<Duration>) -> Self
pub fn with_cleanup_frequency(self, duration: Option<Duration>) -> Self
Set the duration between two automatic media cache cleanups.
Sourcepub fn has_limitations(&self) -> bool
pub fn has_limitations(&self) -> bool
Whether this policy has limitations.
If this policy has no limitations, a cleanup job would have no effect.
Returns true
if at least one limitation is set.
Sourcepub fn exceeds_max_cache_size(&self, size: u64) -> bool
pub fn exceeds_max_cache_size(&self, size: u64) -> bool
Whether the given size exceeds the maximum authorized size of the media cache.
§Arguments
size
- The overall size of the media cache to check, in bytes.
Sourcepub fn computed_max_file_size(&self) -> Option<u64>
pub fn computed_max_file_size(&self) -> Option<u64>
The computed maximum authorized size of a single media content, in bytes.
This is the lowest value between max_cache_size
and max_file_size
.
Sourcepub fn exceeds_max_file_size(&self, size: u64) -> bool
pub fn exceeds_max_file_size(&self, size: u64) -> bool
Whether the given size, in bytes, exceeds the computed maximum authorized size of a single media content.
§Arguments
size
- The size of the media content to check, in bytes.
Sourcepub fn has_content_expired(
&self,
current_time: SystemTime,
last_access_time: SystemTime,
) -> bool
pub fn has_content_expired( &self, current_time: SystemTime, last_access_time: SystemTime, ) -> bool
Whether a content whose last access was at the given time has expired.
§Arguments
-
current_time
- The current time. -
last_access_time
- The time when the media content to check was last accessed.
Sourcepub fn should_clean_up(
&self,
current_time: SystemTime,
last_cleanup_time: SystemTime,
) -> bool
pub fn should_clean_up( &self, current_time: SystemTime, last_cleanup_time: SystemTime, ) -> bool
Whether an automatic media cache cleanup should be triggered given the time of the last cleanup.
§Arguments
-
current_time
- The current time. -
last_cleanup_time
- The time of the last media cache cleanup.
Trait Implementations§
Source§impl Clone for MediaRetentionPolicy
impl Clone for MediaRetentionPolicy
Source§fn clone(&self) -> MediaRetentionPolicy
fn clone(&self) -> MediaRetentionPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<UT> ConvertError<UT> for MediaRetentionPolicy
impl<UT> ConvertError<UT> for MediaRetentionPolicy
fn try_convert_unexpected_callback_error( e: UnexpectedUniFFICallbackError, ) -> Result<Self>
Source§impl Debug for MediaRetentionPolicy
impl Debug for MediaRetentionPolicy
Source§impl Default for MediaRetentionPolicy
impl Default for MediaRetentionPolicy
Source§impl<'de> Deserialize<'de> for MediaRetentionPolicy
impl<'de> Deserialize<'de> for MediaRetentionPolicy
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<UT> FfiConverter<UT> for MediaRetentionPolicy
impl<UT> FfiConverter<UT> for MediaRetentionPolicy
Source§const TYPE_ID_META: MetadataBuffer
const TYPE_ID_META: MetadataBuffer
Source§type FfiType = RustBuffer
type FfiType = RustBuffer
Source§fn lower(v: Self) -> RustBuffer
fn lower(v: Self) -> RustBuffer
Source§fn try_lift(buf: RustBuffer) -> Result<Self>
fn try_lift(buf: RustBuffer) -> Result<Self>
Source§impl<UT> Lift<UT> for MediaRetentionPolicy
impl<UT> Lift<UT> for MediaRetentionPolicy
Source§impl<UT> LiftRef<UT> for MediaRetentionPolicy
impl<UT> LiftRef<UT> for MediaRetentionPolicy
Source§impl<UT> LiftReturn<UT> for MediaRetentionPolicy
impl<UT> LiftReturn<UT> for MediaRetentionPolicy
Source§type ReturnType = <MediaRetentionPolicy as Lift<UT>>::FfiType
type ReturnType = <MediaRetentionPolicy as Lift<UT>>::FfiType
Source§fn try_lift_successful_return(v: Self::ReturnType) -> Result<Self>
fn try_lift_successful_return(v: Self::ReturnType) -> Result<Self>
Source§fn lift_foreign_return(
ffi_return: Self::ReturnType,
call_status: RustCallStatus,
) -> Self
fn lift_foreign_return( ffi_return: Self::ReturnType, call_status: RustCallStatus, ) -> Self
Source§fn lift_error(_buf: RustBuffer) -> Self
fn lift_error(_buf: RustBuffer) -> Self
Source§fn handle_callback_unexpected_error(e: UnexpectedUniFFICallbackError) -> Self
fn handle_callback_unexpected_error(e: UnexpectedUniFFICallbackError) -> Self
Source§impl<UT> Lower<UT> for MediaRetentionPolicy
impl<UT> Lower<UT> for MediaRetentionPolicy
type FfiType = <MediaRetentionPolicy as FfiConverter<UT>>::FfiType
fn lower(obj: Self) -> Self::FfiType
fn write(obj: Self, buf: &mut Vec<u8>)
Source§fn lower_into_rust_buffer(obj: Self) -> RustBuffer
fn lower_into_rust_buffer(obj: Self) -> RustBuffer
Source§impl<UT> LowerError<UT> for MediaRetentionPolicy
impl<UT> LowerError<UT> for MediaRetentionPolicy
Source§fn lower_error(obj: Self) -> RustBuffer
fn lower_error(obj: Self) -> RustBuffer
Source§impl<UT> LowerReturn<UT> for MediaRetentionPolicy
impl<UT> LowerReturn<UT> for MediaRetentionPolicy
Source§type ReturnType = <MediaRetentionPolicy as Lower<UT>>::FfiType
type ReturnType = <MediaRetentionPolicy as Lower<UT>>::FfiType
Source§fn lower_return(obj: Self) -> Result<Self::ReturnType, RustBuffer>
fn lower_return(obj: Self) -> Result<Self::ReturnType, RustBuffer>
Source§impl PartialEq for MediaRetentionPolicy
impl PartialEq for MediaRetentionPolicy
Source§impl Serialize for MediaRetentionPolicy
impl Serialize for MediaRetentionPolicy
Source§impl<UT> TypeId<UT> for MediaRetentionPolicy
impl<UT> TypeId<UT> for MediaRetentionPolicy
impl Copy for MediaRetentionPolicy
impl Eq for MediaRetentionPolicy
impl StructuralPartialEq for MediaRetentionPolicy
Auto Trait Implementations§
impl Freeze for MediaRetentionPolicy
impl RefUnwindSafe for MediaRetentionPolicy
impl Send for MediaRetentionPolicy
impl Sync for MediaRetentionPolicy
impl Unpin for MediaRetentionPolicy
impl UnwindSafe for MediaRetentionPolicy
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<T> CompatExt for T
impl<T> CompatExt for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§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