MediaStoreInner

Trait MediaStoreInner 

pub trait MediaStoreInner: AsyncTraitDeps + Clone {
    type Error: Debug + Display + Into<MediaStoreError>;

    // 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 'life0: 'async_trait,
             Self: '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 'life0: 'async_trait,
             Self: '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 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: '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 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: '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 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: '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 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn clean_inner<'life0, 'async_trait>(
        &'life0 self,
        policy: MediaRetentionPolicy,
        current_time: SystemTime,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn last_media_cleanup_time_inner<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<SystemTime>, Self::Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: '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 SystemTimes provided to the store.

Required Associated Types§

type Error: Debug + Display + Into<MediaStoreError>

The error type used by this media cache store.

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 'life0: 'async_trait, Self: 'async_trait,

The persisted media retention policy in the media cache.

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 'life0: 'async_trait, Self: 'async_trait,

Persist the media retention policy in the media cache.

§Arguments
  • policy - The MediaRetentionPolicy to persist.

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 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Add a media file’s content in the media cache.

§Arguments
  • request - The MediaRequestParameters 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 the MediaRetentionPolicy should be ignored for this media. This setting should be persisted alongside the media and taken into account whenever the policy is used.

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 'life0: 'async_trait, 'life1: 'async_trait, Self: '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 - The MediaRequestParameters of the file.

  • ignore_policy - Whether the current MediaRetentionPolicy should be ignored.

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 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Get a media file’s content out of the media cache.

§Arguments
  • request - The MediaRequestParameters of the file.

  • current_time - The current time, to update the last access time of the media.

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 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Get a media file’s content associated to an MxcUri from the media store.

§Arguments
  • uri - The MxcUri of the media file.

  • current_time - The current time, to update the last access time of the media.

fn clean_inner<'life0, 'async_trait>( &'life0 self, policy: MediaRetentionPolicy, current_time: SystemTime, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: '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. The cleanup_frequency will be ignored.

  • current_time - The current time, to be used to check for expired content and to be stored as the time of the last media cache cleanup.

fn last_media_cleanup_time_inner<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<SystemTime>, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

The time of the last media cache cleanup.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§