pub struct MediaService<Time: TimeProvider = DefaultTimeProvider> { /* private fields */ }
Expand description
API for implementors of EventCacheStore
to manage their media through
their implementation of EventCacheStoreMedia
.
Implementations§
Source§impl MediaService
impl MediaService
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a new default MediaService
.
MediaService::restore()
should be called after constructing the
MediaService
to restore its previous state.
Source§impl<Time> MediaService<Time>where
Time: TimeProvider,
impl<Time> MediaService<Time>where
Time: TimeProvider,
Sourcepub fn restore(&self, policy: Option<MediaRetentionPolicy>)
pub fn restore(&self, policy: Option<MediaRetentionPolicy>)
Restore the previous state of the MediaRetentionPolicy
from data
that was persisted in the store.
This should be called immediately after constructing the MediaService
.
§Arguments
policy
- TheMediaRetentionPolicy
that was persisted in the store.
Sourcepub async fn set_media_retention_policy<Store: EventCacheStoreMedia>(
&self,
store: &Store,
policy: MediaRetentionPolicy,
) -> Result<(), Store::Error>
pub async fn set_media_retention_policy<Store: EventCacheStoreMedia>( &self, store: &Store, policy: MediaRetentionPolicy, ) -> Result<(), Store::Error>
Set the MediaRetentionPolicy
of this service.
§Arguments
-
store
- TheEventCacheStoreMedia
. -
policy
- TheMediaRetentionPolicy
to use.
Sourcepub fn media_retention_policy(&self) -> MediaRetentionPolicy
pub fn media_retention_policy(&self) -> MediaRetentionPolicy
Get the MediaRetentionPolicy
of this service.
Sourcepub async fn add_media_content<Store: EventCacheStoreMedia>(
&self,
store: &Store,
request: &MediaRequestParameters,
content: Vec<u8>,
ignore_policy: IgnoreMediaRetentionPolicy,
) -> Result<(), Store::Error>
pub async fn add_media_content<Store: EventCacheStoreMedia>( &self, store: &Store, request: &MediaRequestParameters, content: Vec<u8>, ignore_policy: IgnoreMediaRetentionPolicy, ) -> Result<(), Store::Error>
Add a media file’s content in the media store.
§Arguments
-
store
- TheEventCacheStoreMedia
. -
request
- TheMediaRequestParameters
of the file. -
content
- The content of the file. -
ignore_policy
- Whether the currentMediaRetentionPolicy
should be ignored.
Sourcepub async fn set_ignore_media_retention_policy<Store: EventCacheStoreMedia>(
&self,
store: &Store,
request: &MediaRequestParameters,
ignore_policy: IgnoreMediaRetentionPolicy,
) -> Result<(), Store::Error>
pub async fn set_ignore_media_retention_policy<Store: EventCacheStoreMedia>( &self, store: &Store, request: &MediaRequestParameters, ignore_policy: IgnoreMediaRetentionPolicy, ) -> Result<(), Store::Error>
Set whether the current MediaRetentionPolicy
should be ignored for
the media.
The change will be taken into account in the next cleanup.
§Arguments
-
store
- TheEventCacheStoreMedia
. -
request
- TheMediaRequestParameters
of the file. -
ignore_policy
- Whether the currentMediaRetentionPolicy
should be ignored.
Sourcepub async fn get_media_content<Store: EventCacheStoreMedia>(
&self,
store: &Store,
request: &MediaRequestParameters,
) -> Result<Option<Vec<u8>>, Store::Error>
pub async fn get_media_content<Store: EventCacheStoreMedia>( &self, store: &Store, request: &MediaRequestParameters, ) -> Result<Option<Vec<u8>>, Store::Error>
Get a media file’s content out of the media store.
§Arguments
-
store
- TheEventCacheStoreMedia
. -
request
- TheMediaRequestParameters
of the file.
Sourcepub async fn get_media_content_for_uri<Store: EventCacheStoreMedia>(
&self,
store: &Store,
uri: &MxcUri,
) -> Result<Option<Vec<u8>>, Store::Error>
pub async fn get_media_content_for_uri<Store: EventCacheStoreMedia>( &self, store: &Store, uri: &MxcUri, ) -> Result<Option<Vec<u8>>, Store::Error>
Get a media file’s content associated to an MxcUri
from the
media store.
§Arguments
-
store
- TheEventCacheStoreMedia
. -
uri
- TheMxcUri
of the media file.
Sourcepub async fn clean_up_media_cache<Store: EventCacheStoreMedia>(
&self,
store: &Store,
) -> Result<(), Store::Error>
pub async fn clean_up_media_cache<Store: EventCacheStoreMedia>( &self, store: &Store, ) -> Result<(), Store::Error>
Clean up the media cache with the current MediaRetentionPolicy
.
If there is already an ongoing cleanup, this is a noop.
§Arguments
store
- TheEventCacheStoreMedia
.
Trait Implementations§
Source§impl<Time: Debug + TimeProvider> Debug for MediaService<Time>
impl<Time: Debug + TimeProvider> Debug for MediaService<Time>
Auto Trait Implementations§
impl<Time = DefaultTimeProvider> !Freeze for MediaService<Time>
impl<Time = DefaultTimeProvider> !RefUnwindSafe for MediaService<Time>
impl<Time> Send for MediaService<Time>where
Time: Send,
impl<Time> Sync for MediaService<Time>where
Time: Sync,
impl<Time> Unpin for MediaService<Time>where
Time: Unpin,
impl<Time> UnwindSafe for MediaService<Time>where
Time: UnwindSafe,
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
§impl<T> CompatExt for T
impl<T> CompatExt for T
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