pub struct Media { /* private fields */ }
Expand description

A high-level API to interact with the media API.

Implementations

Upload some media to the server.

Arguments
  • content_type - The type of the media, this will be used as the content-type header.

  • reader - A Reader that will be used to fetch the raw bytes of the media.

Examples
let image = fs::read("/home/example/my-cat.jpg")?;

let response = client.media().upload(&mime::IMAGE_JPEG, &image).await?;

println!("Cat URI: {}", response.content_uri);

Get a media file’s content.

If the content is encrypted and encryption is enabled, the content will be decrypted.

Arguments
  • request - The MediaRequest of the content.

  • use_cache - If we should use the media cache for this request.

Remove a media file’s content from the store.

Arguments
  • request - The MediaRequest of the content.

Delete all the media content corresponding to the given uri from the store.

Arguments
  • uri - The MxcUri of the files.

Get the file of the given media event content.

If the content is encrypted and encryption is enabled, the content will be decrypted.

Returns Ok(None) if the event content has no file.

This is a convenience method that calls the get_media_content method.

Arguments
  • event_content - The media event content.

  • use_cache - If we should use the media cache for this file.

Remove the file of the given media event content from the cache.

This is a convenience method that calls the remove_media_content method.

Arguments
  • event_content - The media event content.

Get a thumbnail of the given media event content.

If the content is encrypted and encryption is enabled, the content will be decrypted.

Returns Ok(None) if the event content has no thumbnail.

This is a convenience method that calls the get_media_content method.

Arguments
  • event_content - The media event content.

  • size - The desired size of the thumbnail. The actual thumbnail may not match the size specified.

  • use_cache - If we should use the media cache for this thumbnail.

Remove the thumbnail of the given media event content from the cache.

This is a convenience method that calls the remove_media_content method.

Arguments
  • event_content - The media event content.

  • size - The desired size of the thumbnail. Must match the size requested with get_thumbnail.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more