Struct MediaService
pub struct MediaService<Time = DefaultTimeProvider>where
Time: TimeProvider,{ /* private fields */ }Expand description
API for implementors of MediaStore to manage their media through
their implementation of MediaStoreInner.
Implementations§
§impl MediaService
impl MediaService
pub fn new() -> MediaService
pub fn new() -> MediaService
Construct a new default MediaService.
MediaService::restore() should be called after constructing the
MediaService to restore its previous state.
§impl<Time> MediaService<Time>where
Time: TimeProvider + 'static,
impl<Time> MediaService<Time>where
Time: TimeProvider + 'static,
pub fn restore(
&self,
policy: Option<MediaRetentionPolicy>,
last_media_cleanup_time: Option<SystemTime>,
)
pub fn restore( &self, policy: Option<MediaRetentionPolicy>, last_media_cleanup_time: Option<SystemTime>, )
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- TheMediaRetentionPolicythat was persisted in the store.
pub async fn set_media_retention_policy<Store>(
&self,
store: &Store,
policy: MediaRetentionPolicy,
) -> Result<(), <Store as MediaStoreInner>::Error>where
Store: MediaStoreInner + 'static,
pub async fn set_media_retention_policy<Store>(
&self,
store: &Store,
policy: MediaRetentionPolicy,
) -> Result<(), <Store as MediaStoreInner>::Error>where
Store: MediaStoreInner + 'static,
Set the MediaRetentionPolicy of this service.
§Arguments
-
store- TheMediaStoreInner. -
policy- TheMediaRetentionPolicyto use.
pub fn media_retention_policy(&self) -> MediaRetentionPolicy
pub fn media_retention_policy(&self) -> MediaRetentionPolicy
Get the MediaRetentionPolicy of this service.
pub async fn add_media_content<Store>(
&self,
store: &Store,
request: &MediaRequestParameters,
content: Vec<u8>,
ignore_policy: IgnoreMediaRetentionPolicy,
) -> Result<(), <Store as MediaStoreInner>::Error>where
Store: MediaStoreInner + 'static,
pub async fn add_media_content<Store>(
&self,
store: &Store,
request: &MediaRequestParameters,
content: Vec<u8>,
ignore_policy: IgnoreMediaRetentionPolicy,
) -> Result<(), <Store as MediaStoreInner>::Error>where
Store: MediaStoreInner + 'static,
Add a media file’s content in the media store.
§Arguments
-
store- TheMediaStoreInner. -
request- TheMediaRequestParametersof the file. -
content- The content of the file. -
ignore_policy- Whether the currentMediaRetentionPolicyshould be ignored.
pub async fn set_ignore_media_retention_policy<Store>(
&self,
store: &Store,
request: &MediaRequestParameters,
ignore_policy: IgnoreMediaRetentionPolicy,
) -> Result<(), <Store as MediaStoreInner>::Error>where
Store: MediaStoreInner,
pub async fn set_ignore_media_retention_policy<Store>(
&self,
store: &Store,
request: &MediaRequestParameters,
ignore_policy: IgnoreMediaRetentionPolicy,
) -> Result<(), <Store as MediaStoreInner>::Error>where
Store: MediaStoreInner,
Set whether the current MediaRetentionPolicy should be ignored for
the media.
The change will be taken into account in the next cleanup.
§Arguments
-
store- TheMediaStoreInner. -
request- TheMediaRequestParametersof the file. -
ignore_policy- Whether the currentMediaRetentionPolicyshould be ignored.
pub async fn get_media_content<Store>(
&self,
store: &Store,
request: &MediaRequestParameters,
) -> Result<Option<Vec<u8>>, <Store as MediaStoreInner>::Error>where
Store: MediaStoreInner + 'static,
pub async fn get_media_content<Store>(
&self,
store: &Store,
request: &MediaRequestParameters,
) -> Result<Option<Vec<u8>>, <Store as MediaStoreInner>::Error>where
Store: MediaStoreInner + 'static,
Get a media file’s content out of the media store.
§Arguments
-
store- TheMediaStoreInner. -
request- TheMediaRequestParametersof the file.
pub async fn get_media_content_for_uri<Store>(
&self,
store: &Store,
uri: &MxcUri,
) -> Result<Option<Vec<u8>>, <Store as MediaStoreInner>::Error>where
Store: MediaStoreInner + 'static,
pub async fn get_media_content_for_uri<Store>(
&self,
store: &Store,
uri: &MxcUri,
) -> Result<Option<Vec<u8>>, <Store as MediaStoreInner>::Error>where
Store: MediaStoreInner + 'static,
Get a media file’s content associated to an MxcUri from the
media store.
§Arguments
-
store- TheMediaStoreInner. -
uri- TheMxcUriof the media file.
pub async fn clean<Store>(
&self,
store: &Store,
) -> Result<(), <Store as MediaStoreInner>::Error>where
Store: MediaStoreInner,
pub async fn clean<Store>(
&self,
store: &Store,
) -> Result<(), <Store as MediaStoreInner>::Error>where
Store: MediaStoreInner,
Clean up the media cache with the current MediaRetentionPolicy.
If there is already an ongoing cleanup, this is a noop.
§Arguments
store- TheMediaStoreInner.
Trait Implementations§
§impl<Time> Clone for MediaService<Time>where
Time: TimeProvider,
impl<Time> Clone for MediaService<Time>where
Time: TimeProvider,
§fn clone(&self) -> MediaService<Time>
fn clone(&self) -> MediaService<Time>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl<Time> Debug for MediaService<Time>where
Time: Debug + TimeProvider,
impl<Time> Debug for MediaService<Time>where
Time: Debug + TimeProvider,
§impl Default for MediaService
impl Default for MediaService
§fn default() -> MediaService
fn default() -> MediaService
Auto Trait Implementations§
impl<Time> Freeze for MediaService<Time>
impl<Time = DefaultTimeProvider> !RefUnwindSafe for MediaService<Time>
impl<Time> Send for MediaService<Time>
impl<Time> Sync for MediaService<Time>
impl<Time> Unpin for MediaService<Time>
impl<Time = DefaultTimeProvider> !UnwindSafe for MediaService<Time>
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
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