Struct matrix_sdk::ruma::events::room::message::FileMessageEventContent
source · #[non_exhaustive]pub struct FileMessageEventContent {
pub body: String,
pub formatted: Option<FormattedBody>,
pub filename: Option<String>,
pub source: MediaSource,
pub info: Option<Box<FileInfo>>,
}
Expand description
The payload for a file message.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.body: String
A human-readable description of the file.
If the filename
field is not set or has the same value, this is the filename of the
uploaded file. Otherwise, this should be interpreted as a user-written media caption.
formatted: Option<FormattedBody>
Formatted form of the message body
.
This should only be set if the body represents a caption.
filename: Option<String>
The original filename of the uploaded file as deserialized from the event.
It is recommended to use the filename
method to get the filename which automatically
falls back to the body
field when the filename
field is not set.
source: MediaSource
The source of the file.
info: Option<Box<FileInfo>>
Metadata about the file referred to in source
.
Implementations§
source§impl FileMessageEventContent
impl FileMessageEventContent
sourcepub fn new(body: String, source: MediaSource) -> FileMessageEventContent
pub fn new(body: String, source: MediaSource) -> FileMessageEventContent
Creates a new FileMessageEventContent
with the given body and source.
sourcepub fn plain(body: String, url: OwnedMxcUri) -> FileMessageEventContent
pub fn plain(body: String, url: OwnedMxcUri) -> FileMessageEventContent
Creates a new non-encrypted FileMessageEventContent
with the given body and url.
sourcepub fn encrypted(body: String, file: EncryptedFile) -> FileMessageEventContent
pub fn encrypted(body: String, file: EncryptedFile) -> FileMessageEventContent
Creates a new encrypted FileMessageEventContent
with the given body and encrypted
file.
sourcepub fn info(
self,
info: impl Into<Option<Box<FileInfo>>>,
) -> FileMessageEventContent
pub fn info( self, info: impl Into<Option<Box<FileInfo>>>, ) -> FileMessageEventContent
Creates a new FileMessageEventContent
from self
with the info
field set to the given
value.
Since the field is public, you can also assign to it directly. This method merely acts as a shorthand for that, because it is very common to set this field.
sourcepub fn filename(&self) -> &str
pub fn filename(&self) -> &str
Computes the filename for the file as defined by the spec.
This differs from the filename
field as this method falls back to the body
field when
the filename
field is not set.
Returns the caption of the media file as defined by the spec.
In short, this is the body
field if the filename
field exists and has a different value,
otherwise the media file does not have a caption.
Returns the formatted caption of the media file as defined by the spec.
This is the same as caption
, but returns the formatted body instead of the plain body.
Trait Implementations§
source§impl Clone for FileMessageEventContent
impl Clone for FileMessageEventContent
source§fn clone(&self) -> FileMessageEventContent
fn clone(&self) -> FileMessageEventContent
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FileMessageEventContent
impl Debug for FileMessageEventContent
source§impl<'de> Deserialize<'de> for FileMessageEventContent
impl<'de> Deserialize<'de> for FileMessageEventContent
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<FileMessageEventContent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<FileMessageEventContent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl MediaEventContent for FileMessageEventContent
impl MediaEventContent for FileMessageEventContent
source§fn thumbnail_source(&self) -> Option<MediaSource>
fn thumbnail_source(&self) -> Option<MediaSource>
Self
. Read moresource§impl Serialize for FileMessageEventContent
impl Serialize for FileMessageEventContent
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for FileMessageEventContent
impl RefUnwindSafe for FileMessageEventContent
impl Send for FileMessageEventContent
impl Sync for FileMessageEventContent
impl Unpin for FileMessageEventContent
impl UnwindSafe for FileMessageEventContent
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> CompatExt for T
impl<T> CompatExt for T
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
source§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
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