pub enum VisualMediaMessage {
Image(ImageMessageEventContent),
Video(VideoMessageEventContent),
Sticker(StickerEventContent),
}
Expand description
A visual media message.
Variants§
Image(ImageMessageEventContent)
An image.
Video(VideoMessageEventContent)
A video.
Sticker(StickerEventContent)
A sticker.
Implementations§
Source§impl VisualMediaMessage
impl VisualMediaMessage
Sourcepub fn from_message(msgtype: &MessageType) -> Option<Self>
pub fn from_message(msgtype: &MessageType) -> Option<Self>
Construct a VisualMediaMessage
from the given message.
Sourcepub fn filename(&self) -> String
pub fn filename(&self) -> String
The filename of the media.
For a sticker, this returns the description of the sticker.
The caption of the media, if any.
Returns Some((body, formatted_body))
if the media includes a caption.
Sourcepub fn dimensions(&self) -> Option<(UInt, UInt)>
pub fn dimensions(&self) -> Option<(UInt, UInt)>
The dimensions of the media, if any.
Returns a (width, height)
tuple.
Sourcepub async fn thumbnail(
&self,
client: Client,
settings: ThumbnailSettings,
priority: ImageRequestPriority,
) -> Result<Option<Image>, ImageError>
pub async fn thumbnail( &self, client: Client, settings: ThumbnailSettings, priority: ImageRequestPriority, ) -> Result<Option<Image>, ImageError>
Fetch a thumbnail of the media with the given client and thumbnail settings.
This might not return a thumbnail at the requested size, depending on the message and the homeserver.
Returns Ok(None)
if no thumbnail could be retrieved and no fallback
could be downloaded. This only applies to video messages.
Returns an error if something occurred while fetching the content or loading it.
Sourcepub async fn into_content(self, client: &Client) -> Result<Vec<u8>, Error>
pub async fn into_content(self, client: &Client) -> Result<Vec<u8>, Error>
Fetch the content of the media with the given client.
Returns an error if something occurred while fetching the content.
Sourcepub async fn into_tmp_file(
self,
client: &Client,
) -> Result<File, MediaFileError>
pub async fn into_tmp_file( self, client: &Client, ) -> Result<File, MediaFileError>
Fetch the content of the media with the given client and write it to a temporary file.
Returns an error if something occurred while fetching the content or saving the content to a file.
Sourcepub async fn save_to_file(self, client: &Client, parent: &impl IsA<Widget>)
pub async fn save_to_file(self, client: &Client, parent: &impl IsA<Widget>)
Save the content of the media to a file selected by the user.
Shows a dialog to the user to select a file on the system.
Trait Implementations§
Source§impl Clone for VisualMediaMessage
impl Clone for VisualMediaMessage
Source§fn clone(&self) -> VisualMediaMessage
fn clone(&self) -> VisualMediaMessage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for VisualMediaMessage
impl Debug for VisualMediaMessage
Source§impl From<ImageMessageEventContent> for VisualMediaMessage
impl From<ImageMessageEventContent> for VisualMediaMessage
Source§impl From<StickerEventContent> for VisualMediaMessage
impl From<StickerEventContent> for VisualMediaMessage
Source§impl From<VideoMessageEventContent> for VisualMediaMessage
impl From<VideoMessageEventContent> for VisualMediaMessage
Source§impl From<VisualMediaMessage> for MediaMessage
impl From<VisualMediaMessage> for MediaMessage
Source§fn from(value: VisualMediaMessage) -> Self
fn from(value: VisualMediaMessage) -> Self
Auto Trait Implementations§
impl Freeze for VisualMediaMessage
impl RefUnwindSafe for VisualMediaMessage
impl Send for VisualMediaMessage
impl Sync for VisualMediaMessage
impl Unpin for VisualMediaMessage
impl UnwindSafe for VisualMediaMessage
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,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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