Enum fractal::utils::matrix::media_message::MediaMessage
source · pub enum MediaMessage {
Audio(AudioMessageEventContent),
File(FileMessageEventContent),
Image(ImageMessageEventContent),
Video(VideoMessageEventContent),
Sticker(StickerEventContent),
}
Expand description
A media message.
Variants§
Audio(AudioMessageEventContent)
An audio.
File(FileMessageEventContent)
A file.
Image(ImageMessageEventContent)
An image.
Video(VideoMessageEventContent)
A video.
Sticker(StickerEventContent)
A sticker.
Implementations§
source§impl MediaMessage
impl MediaMessage
sourcepub fn from_message(msgtype: &MessageType) -> Option<Self>
pub fn from_message(msgtype: &MessageType) -> Option<Self>
Construct a MediaMessage
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.
sourcepub fn caption(&self) -> Option<(String, Option<FormattedBody>)>
pub 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 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.
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 MediaMessage
impl Clone for MediaMessage
source§fn clone(&self) -> MediaMessage
fn clone(&self) -> MediaMessage
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for MediaMessage
impl RefUnwindSafe for MediaMessage
impl Send for MediaMessage
impl Sync for MediaMessage
impl Unpin 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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
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>
Converts
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>
Converts
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