pub trait EventCacheStoreMedia: AsyncTraitDeps {
type Error: Debug + Into<EventCacheStoreError>;
// Required methods
fn media_retention_policy_inner<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<MediaRetentionPolicy>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn set_media_retention_policy_inner<'life0, 'async_trait>(
&'life0 self,
policy: MediaRetentionPolicy,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn add_media_content_inner<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 MediaRequestParameters,
content: Vec<u8>,
current_time: SystemTime,
policy: MediaRetentionPolicy,
ignore_policy: IgnoreMediaRetentionPolicy,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn set_ignore_media_retention_policy_inner<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 MediaRequestParameters,
ignore_policy: IgnoreMediaRetentionPolicy,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_media_content_inner<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 MediaRequestParameters,
current_time: SystemTime,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_media_content_for_uri_inner<'life0, 'life1, 'async_trait>(
&'life0 self,
uri: &'life1 MxcUri,
current_time: SystemTime,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn clean_up_media_cache_inner<'life0, 'async_trait>(
&'life0 self,
policy: MediaRetentionPolicy,
current_time: SystemTime,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
An abstract trait that can be used to implement different store backends for the media cache of the SDK.
The main purposes of this trait are to be able to centralize where we handle
MediaRetentionPolicy
by wrapping this in a MediaService
, and to
simplify the implementation of tests by being able to have complete control
over the SystemTime
s provided to the store.
Required Associated Types§
Sourcetype Error: Debug + Into<EventCacheStoreError>
type Error: Debug + Into<EventCacheStoreError>
The error type used by this media cache store.
Required Methods§
Sourcefn media_retention_policy_inner<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<MediaRetentionPolicy>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn media_retention_policy_inner<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<MediaRetentionPolicy>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
The persisted media retention policy in the media cache.
Sourcefn set_media_retention_policy_inner<'life0, 'async_trait>(
&'life0 self,
policy: MediaRetentionPolicy,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_media_retention_policy_inner<'life0, 'async_trait>(
&'life0 self,
policy: MediaRetentionPolicy,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Persist the media retention policy in the media cache.
§Arguments
policy
- TheMediaRetentionPolicy
to persist.
Sourcefn add_media_content_inner<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 MediaRequestParameters,
content: Vec<u8>,
current_time: SystemTime,
policy: MediaRetentionPolicy,
ignore_policy: IgnoreMediaRetentionPolicy,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_media_content_inner<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 MediaRequestParameters,
content: Vec<u8>,
current_time: SystemTime,
policy: MediaRetentionPolicy,
ignore_policy: IgnoreMediaRetentionPolicy,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Add a media file’s content in the media cache.
§Arguments
-
request
- TheMediaRequestParameters
of the file. -
content
- The content of the file. -
current_time
- The current time, to set the last access time of the media. -
policy
- The media retention policy, to check whether the media is too big to be cached. -
ignore_policy
- Whether theMediaRetentionPolicy
should be ignored for this media. This setting should be persisted alongside the media and taken into account whenever the policy is used.
Sourcefn set_ignore_media_retention_policy_inner<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 MediaRequestParameters,
ignore_policy: IgnoreMediaRetentionPolicy,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_ignore_media_retention_policy_inner<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 MediaRequestParameters,
ignore_policy: IgnoreMediaRetentionPolicy,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Set whether the current MediaRetentionPolicy
should be ignored for
the media.
If the media of the given request is not found, this should be a noop.
The change will be taken into account in the next cleanup.
§Arguments
-
request
- TheMediaRequestParameters
of the file. -
ignore_policy
- Whether the currentMediaRetentionPolicy
should be ignored.
Sourcefn get_media_content_inner<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 MediaRequestParameters,
current_time: SystemTime,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_media_content_inner<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 MediaRequestParameters,
current_time: SystemTime,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a media file’s content out of the media cache.
§Arguments
-
request
- TheMediaRequestParameters
of the file. -
current_time
- The current time, to update the last access time of the media.
Sourcefn get_media_content_for_uri_inner<'life0, 'life1, 'async_trait>(
&'life0 self,
uri: &'life1 MxcUri,
current_time: SystemTime,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_media_content_for_uri_inner<'life0, 'life1, 'async_trait>(
&'life0 self,
uri: &'life1 MxcUri,
current_time: SystemTime,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a media file’s content associated to an MxcUri
from the
media store.
§Arguments
-
uri
- TheMxcUri
of the media file. -
current_time
- The current time, to update the last access time of the media.
Sourcefn clean_up_media_cache_inner<'life0, 'async_trait>(
&'life0 self,
policy: MediaRetentionPolicy,
current_time: SystemTime,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clean_up_media_cache_inner<'life0, 'async_trait>(
&'life0 self,
policy: MediaRetentionPolicy,
current_time: SystemTime,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Clean up the media cache with the given policy.
For the integration tests, it is expected that content that does not pass the last access expiry and max file size criteria will be removed first. After that, the remaining cache size should be computed to compare against the max cache size criteria.
§Arguments
-
policy
- The media retention policy to use for the cleanup. Thecleanup_frequency
will be ignored. -
current_time
- The current time, to be used to check for expired content.