#[non_exhaustive]pub struct AudioMessageEventContent {
pub body: String,
pub formatted: Option<FormattedBody>,
pub filename: Option<String>,
pub source: MediaSource,
pub info: Option<Box<AudioInfo>>,
pub audio: Option<UnstableAudioDetailsContentBlock>,
pub voice: Option<UnstableVoiceContentBlock>,
}
Expand description
The payload for an audio 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
The textual representation of this message.
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 audio clip.
info: Option<Box<AudioInfo>>
Metadata for the audio clip referred to in source
.
audio: Option<UnstableAudioDetailsContentBlock>
unstable-msc3245-v1-compat
only.Extensible event fallback data for audio messages, from the first version of MSC3245.
voice: Option<UnstableVoiceContentBlock>
unstable-msc3245-v1-compat
only.Extensible event fallback data for voice messages, from the first version of MSC3245.
Implementations§
Source§impl AudioMessageEventContent
impl AudioMessageEventContent
Sourcepub fn new(body: String, source: MediaSource) -> AudioMessageEventContent
pub fn new(body: String, source: MediaSource) -> AudioMessageEventContent
Creates a new AudioMessageEventContent
with the given body and source.
Sourcepub fn plain(body: String, url: OwnedMxcUri) -> AudioMessageEventContent
pub fn plain(body: String, url: OwnedMxcUri) -> AudioMessageEventContent
Creates a new non-encrypted AudioMessageEventContent
with the given body and url.
Sourcepub fn encrypted(body: String, file: EncryptedFile) -> AudioMessageEventContent
pub fn encrypted(body: String, file: EncryptedFile) -> AudioMessageEventContent
Creates a new encrypted AudioMessageEventContent
with the given body and encrypted
file.
Sourcepub fn info(
self,
info: impl Into<Option<Box<AudioInfo>>>,
) -> AudioMessageEventContent
pub fn info( self, info: impl Into<Option<Box<AudioInfo>>>, ) -> AudioMessageEventContent
Creates a new AudioMessageEventContent
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 audio 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 for the audio 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 for the audio 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 AudioMessageEventContent
impl Clone for AudioMessageEventContent
Source§fn clone(&self) -> AudioMessageEventContent
fn clone(&self) -> AudioMessageEventContent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for AudioMessageEventContent
impl Debug for AudioMessageEventContent
Source§impl<'de> Deserialize<'de> for AudioMessageEventContent
impl<'de> Deserialize<'de> for AudioMessageEventContent
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<AudioMessageEventContent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<AudioMessageEventContent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl MediaEventContent for AudioMessageEventContent
impl MediaEventContent for AudioMessageEventContent
Source§fn thumbnail_source(&self) -> Option<MediaSource>
fn thumbnail_source(&self) -> Option<MediaSource>
Self
. Read moreSource§impl Serialize for AudioMessageEventContent
impl Serialize for AudioMessageEventContent
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 AudioMessageEventContent
impl RefUnwindSafe for AudioMessageEventContent
impl Send for AudioMessageEventContent
impl Sync for AudioMessageEventContent
impl Unpin for AudioMessageEventContent
impl UnwindSafe for AudioMessageEventContent
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,
§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