pub(crate) enum MediaMessage {
Audio(AudioMessageEventContent),
File(FileMessageEventContent),
Image(ImageMessageEventContent),
Video(VideoMessageEventContent),
Sticker(Box<StickerEventContent>),
}Expand description
A media message.
Variants§
Audio(AudioMessageEventContent)
An audio.
File(FileMessageEventContent)
A file.
Image(ImageMessageEventContent)
An image.
Video(VideoMessageEventContent)
A video.
Sticker(Box<StickerEventContent>)
A sticker.
Implementations§
Source§impl MediaMessage
impl MediaMessage
Sourcepub(crate) fn from_message(msgtype: &MessageType) -> Option<Self>
pub(crate) fn from_message(msgtype: &MessageType) -> Option<Self>
Construct a MediaMessage from the given message.
Sourcepub(crate) fn display_name(&self) -> String
pub(crate) fn display_name(&self) -> String
The name of the media, as displayed in the interface.
This is usually the filename in the message, except:
- For a voice message, it’s a placeholder string because file names are usually generated randomly.
- For a sticker, this returns the description of the sticker, because they do not have a filename.
Sourcepub(crate) fn filename(&self, timestamp: &DateTime) -> String
pub(crate) fn filename(&self, timestamp: &DateTime) -> String
The filename of the media, used when saving the file.
This is usually the filename in the message, except:
- For a voice message, it’s a generated name that uses the timestamp of the message.
- For a sticker, this returns the description of the sticker, because they do not have a filename.
Sourcepub(crate) fn caption(&self) -> Option<(String, Option<FormattedBody>)>
pub(crate) fn caption(&self) -> Option<(String, Option<FormattedBody>)>
The caption of the media, if any.
Returns Some((body, formatted_body)) if the media includes a caption.
Sourcepub(crate) async fn into_content(
self,
client: &Client,
) -> Result<Vec<u8>, Error>
pub(crate) 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(crate) async fn into_tmp_file(
self,
client: &Client,
) -> Result<File, MediaFileError>
pub(crate) 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.
Sourcepub(crate) async fn save_to_file(
self,
timestamp: &DateTime,
client: &Client,
parent: &impl IsA<Widget>,
)
pub(crate) async fn save_to_file( self, timestamp: &DateTime, 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 MediaMessage
impl Clone for MediaMessage
Source§fn clone(&self) -> MediaMessage
fn clone(&self) -> MediaMessage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MediaMessage
impl Debug for MediaMessage
Source§impl From<AudioMessageEventContent> for MediaMessage
impl From<AudioMessageEventContent> for MediaMessage
Source§impl From<FileMessageEventContent> for MediaMessage
impl From<FileMessageEventContent> for MediaMessage
Source§impl From<StickerEventContent> for MediaMessage
impl From<StickerEventContent> for MediaMessage
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 MediaMessage
impl RefUnwindSafe for MediaMessage
impl Send for MediaMessage
impl Sync for MediaMessage
impl Unpin for MediaMessage
impl UnsafeUnpin for MediaMessage
impl UnwindSafe for MediaMessage
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§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