Enum ruma_common::events::room::message::MessageType
source · [−]pub enum MessageType {
Audio(AudioMessageEventContent),
Emote(EmoteMessageEventContent),
File(FileMessageEventContent),
Image(ImageMessageEventContent),
Location(LocationMessageEventContent),
Notice(NoticeMessageEventContent),
ServerNotice(ServerNoticeMessageEventContent),
Text(TextMessageEventContent),
Video(VideoMessageEventContent),
VerificationRequest(KeyVerificationRequestEventContent),
// some variants omitted
}events only.Expand description
The content that is specific to each message type variant.
Variants
Audio(AudioMessageEventContent)
An audio message.
Emote(EmoteMessageEventContent)
An emote message.
File(FileMessageEventContent)
A file message.
Image(ImageMessageEventContent)
An image message.
Location(LocationMessageEventContent)
A location message.
Notice(NoticeMessageEventContent)
A notice message.
ServerNotice(ServerNoticeMessageEventContent)
A server notice message.
Text(TextMessageEventContent)
A text message.
Video(VideoMessageEventContent)
A video message.
VerificationRequest(KeyVerificationRequestEventContent)
A request to initiate a key verification.
Implementations
sourceimpl MessageType
impl MessageType
sourcepub fn new(msgtype: &str, body: String, data: JsonObject) -> Result<Self>
pub fn new(msgtype: &str, body: String, data: JsonObject) -> Result<Self>
Creates a new MessageType.
The msgtype and body are required fields as defined by the m.room.message spec.
Additionally it’s possible to add arbitrary key/value pairs to the event content for custom
events through the data map.
Prefer to use the public variants of MessageType where possible; this constructor is meant
be used for unsupported message types only and does not allow setting arbitrary data for
supported ones.
Errors
Returns an error if the msgtype is known and serialization of data to the corresponding
MessageType variant fails.
sourcepub fn data(&self) -> Cow<'_, JsonObject>
pub fn data(&self) -> Cow<'_, JsonObject>
Returns the associated data.
The returned JSON object won’t contain the msgtype and body fields, use
.msgtype() / .body() to access those.
Prefer to use the public variants of MessageType where possible; this method is meant to
be used for custom message types only.
Trait Implementations
sourceimpl Clone for MessageType
impl Clone for MessageType
sourcefn clone(&self) -> MessageType
fn clone(&self) -> MessageType
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more