pub struct RoomMessageEventContent {
pub msgtype: MessageType,
pub relates_to: Option<Relation>,
}
events
only.Expand description
The content of an m.room.message
event.
This event is used when sending messages in a room.
Messages are not limited to be text.
Fields
msgtype: MessageType
A key which identifies the type of message being sent.
This also holds the specific content of each message.
relates_to: Option<Relation>
Information about related messages for rich replies.
Implementations
sourceimpl RoomMessageEventContent
impl RoomMessageEventContent
sourcepub fn new(msgtype: MessageType) -> RoomMessageEventContent
pub fn new(msgtype: MessageType) -> RoomMessageEventContent
Create a RoomMessageEventContent
with the given MessageType
.
sourcepub fn text_plain(body: impl Into<String>) -> RoomMessageEventContent
pub fn text_plain(body: impl Into<String>) -> RoomMessageEventContent
A constructor to create a plain text message.
sourcepub fn text_html(
body: impl Into<String>,
html_body: impl Into<String>
) -> RoomMessageEventContent
pub fn text_html(
body: impl Into<String>,
html_body: impl Into<String>
) -> RoomMessageEventContent
A constructor to create an html message.
sourcepub fn text_markdown(
body: impl AsRef<str> + Into<String>
) -> RoomMessageEventContent
Available on crate feature markdown
only.
pub fn text_markdown(
body: impl AsRef<str> + Into<String>
) -> RoomMessageEventContent
markdown
only.A constructor to create a markdown message.
sourcepub fn notice_plain(body: impl Into<String>) -> RoomMessageEventContent
pub fn notice_plain(body: impl Into<String>) -> RoomMessageEventContent
A constructor to create a plain text notice.
sourcepub fn notice_html(
body: impl Into<String>,
html_body: impl Into<String>
) -> RoomMessageEventContent
pub fn notice_html(
body: impl Into<String>,
html_body: impl Into<String>
) -> RoomMessageEventContent
A constructor to create an html notice.
sourcepub fn notice_markdown(
body: impl AsRef<str> + Into<String>
) -> RoomMessageEventContent
Available on crate feature markdown
only.
pub fn notice_markdown(
body: impl AsRef<str> + Into<String>
) -> RoomMessageEventContent
markdown
only.A constructor to create a markdown notice.
sourcepub fn make_reply_to(
self,
original_message: &OriginalMessageLikeEvent<RoomMessageEventContent>
) -> RoomMessageEventContent
pub fn make_reply_to(
self,
original_message: &OriginalMessageLikeEvent<RoomMessageEventContent>
) -> RoomMessageEventContent
Turns self
into a reply to the given message.
Takes the body
/ formatted_body
(if any) in self
for the main text and prepends a
quoted version of original_message
. Also sets the in_reply_to
field inside relates_to
.
This function requires an OriginalRoomMessageEvent
since it creates a permalink to
the previous message, for which the room ID is required. If you want to reply to an
OriginalSyncRoomMessageEvent
, you have to convert it first by calling
.into_full_event()
.
If the message was edited, the previous message should be the original message that was edited, with the content of its replacement, to allow the fallback to be accurate at the time it is added.
It is recommended to enable the sanitize
feature when using this method as this will
clean up nested rich reply fallbacks in chains of replies. This uses sanitize_html()
internally, with RemoveReplyFallback::Yes
.
Panics
Panics if self
has a formatted_body
with a format other than HTML.
sourcepub fn text_reply_plain(
reply: impl Display,
original_message: &OriginalMessageLikeEvent<RoomMessageEventContent>
) -> RoomMessageEventContent
👎Deprecated: use Self::text_plain
(reply).
make_reply_to
(original_message)
instead
pub fn text_reply_plain(
reply: impl Display,
original_message: &OriginalMessageLikeEvent<RoomMessageEventContent>
) -> RoomMessageEventContent
use Self::text_plain
(reply).
make_reply_to
(original_message)
instead
Creates a plain text reply to a message.
This function requires an OriginalRoomMessageEvent
since it creates a permalink to
the previous message, for which the room ID is required. If you want to reply to an
OriginalSyncRoomMessageEvent
, you have to convert it first by calling
.into_full_event()
.
If the message was edited, the previous message should be the original message that was edited, with the content of its replacement, to allow the fallback to be accurate at the time it is added.
It is recommended to enable the sanitize
feature when using this method as this will
clean up nested rich reply fallbacks in chains of replies. This uses sanitize_html()
internally, with RemoveReplyFallback::Yes
.
sourcepub fn text_reply_html(
reply: impl Display,
html_reply: impl Display,
original_message: &OriginalMessageLikeEvent<RoomMessageEventContent>
) -> RoomMessageEventContent
👎Deprecated: use Self::text_html
(reply, html_reply).
make_reply_to
(original_message)
instead
pub fn text_reply_html(
reply: impl Display,
html_reply: impl Display,
original_message: &OriginalMessageLikeEvent<RoomMessageEventContent>
) -> RoomMessageEventContent
use Self::text_html
(reply, html_reply).
make_reply_to
(original_message)
instead
Creates a html text reply to a message.
This function requires an OriginalRoomMessageEvent
since it creates a permalink to
the previous message, for which the room ID is required. If you want to reply to an
OriginalSyncRoomMessageEvent
, you have to convert it first by calling
.into_full_event()
.
If the message was edited, the previous message should be the original message that was edited, with the content of its replacement, to allow the fallback to be accurate at the time it is added.
It is recommended to enable the sanitize
feature when using this method as this will
clean up nested rich reply fallbacks in chains of replies. This uses sanitize_html()
internally, with RemoveReplyFallback::Yes
.
sourcepub fn notice_reply_plain(
reply: impl Display,
original_message: &OriginalMessageLikeEvent<RoomMessageEventContent>
) -> RoomMessageEventContent
👎Deprecated: use Self::notice_plain
(reply).
make_reply_to
(original_message)
instead
pub fn notice_reply_plain(
reply: impl Display,
original_message: &OriginalMessageLikeEvent<RoomMessageEventContent>
) -> RoomMessageEventContent
use Self::notice_plain
(reply).
make_reply_to
(original_message)
instead
Creates a plain text notice reply to a message.
This function requires an OriginalRoomMessageEvent
since it creates a permalink to
the previous message, for which the room ID is required. If you want to reply to an
OriginalSyncRoomMessageEvent
, you have to convert it first by calling
.into_full_event()
.
If the message was edited, the previous message should be the original message that was edited, with the content of its replacement, to allow the fallback to be accurate at the time it is added.
It is recommended to enable the sanitize
feature when using this method as this will
clean up nested rich reply fallbacks in chains of replies. This uses sanitize_html()
internally, with RemoveReplyFallback::Yes
.
sourcepub fn notice_reply_html(
reply: impl Display,
html_reply: impl Display,
original_message: &OriginalMessageLikeEvent<RoomMessageEventContent>
) -> RoomMessageEventContent
👎Deprecated: use Self::notice_html
(reply, html_reply).
make_reply_to
(original_message)
instead
pub fn notice_reply_html(
reply: impl Display,
html_reply: impl Display,
original_message: &OriginalMessageLikeEvent<RoomMessageEventContent>
) -> RoomMessageEventContent
use Self::notice_html
(reply, html_reply).
make_reply_to
(original_message)
instead
Creates a html text notice reply to a message.
This function requires an OriginalRoomMessageEvent
since it creates a permalink to
the previous message, for which the room ID is required. If you want to reply to an
OriginalSyncRoomMessageEvent
, you have to convert it first by calling
.into_full_event()
.
If the message was edited, the previous message should be the original message that was edited, with the content of its replacement, to allow the fallback to be accurate at the time it is added.
It is recommended to enable the sanitize
feature when using this method as this will
clean up nested rich reply fallbacks in chains of replies. This uses sanitize_html()
internally, with RemoveReplyFallback::Yes
.
sourcepub fn reply(
message: MessageType,
original_message: &OriginalMessageLikeEvent<RoomMessageEventContent>,
forward_thread: ForwardThread
) -> RoomMessageEventContent
Available on crate feature unstable-msc3440
only.
pub fn reply(
message: MessageType,
original_message: &OriginalMessageLikeEvent<RoomMessageEventContent>,
forward_thread: ForwardThread
) -> RoomMessageEventContent
unstable-msc3440
only.Create a new reply with the given message and optionally forwards the Relation::Thread
.
If message
is a text, an emote or a notice message, it is modified to include the rich
reply fallback.
This function requires an OriginalRoomMessageEvent
since it creates a permalink to
the previous message, for which the room ID is required. If you want to reply to an
OriginalSyncRoomMessageEvent
, you have to convert it first by calling
.into_full_event()
.
If the message was edited, the previous message should be the original message that was edited, with the content of its replacement, to allow the fallback to be accurate at the time it is added.
It is recommended to enable the sanitize
feature when using this method as this will
clean up nested rich reply fallbacks in chains of replies. This uses sanitize_html()
internally, with RemoveReplyFallback::Yes
.
sourcepub fn for_thread(
message: MessageType,
previous_message: &OriginalMessageLikeEvent<RoomMessageEventContent>,
is_reply: ReplyInThread
) -> RoomMessageEventContent
Available on crate feature unstable-msc3440
only.
pub fn for_thread(
message: MessageType,
previous_message: &OriginalMessageLikeEvent<RoomMessageEventContent>,
is_reply: ReplyInThread
) -> RoomMessageEventContent
unstable-msc3440
only.Create a new message for a thread that is optionally a reply.
Looks for a Relation::Thread
in previous_message
. If it exists, a message for the same
thread is created. If it doesn’t, a new thread with previous_message
as the root is
created.
If message
is a text, an emote or a notice message, and this is a reply in the thread, it
is modified to include the rich reply fallback.
This function requires an OriginalRoomMessageEvent
since it creates a permalink to
the previous message, for which the room ID is required. If you want to reply to an
OriginalSyncRoomMessageEvent
, you have to convert it first by calling
.into_full_event()
.
If the message was edited, the previous message should be the original message that was edited, with the content of its replacement, to allow the fallback to be accurate at the time it is added.
It is recommended to enable the sanitize
feature when using this method as this will
clean up nested rich reply fallbacks in chains of replies. This uses sanitize_html()
internally, with RemoveReplyFallback::Yes
.
sourcepub fn msgtype(&self) -> &str
pub fn msgtype(&self) -> &str
Returns a reference to the msgtype
string.
If you want to access the message type-specific data rather than the message type itself,
use the msgtype
field, not this method.
sourcepub fn sanitize(
&mut self,
mode: HtmlSanitizerMode,
remove_reply_fallback: RemoveReplyFallback
)
Available on crate feature unstable-sanitize
only.
pub fn sanitize(
&mut self,
mode: HtmlSanitizerMode,
remove_reply_fallback: RemoveReplyFallback
)
unstable-sanitize
only.Sanitize this message.
If this message contains HTML, this removes the tags and attributes that are not listed in the Matrix specification.
It can also optionally remove the rich reply fallback from the plain text and HTML message.
This method is only effective on text, notice and emote messages.
Trait Implementations
sourceimpl Clone for RoomMessageEventContent
impl Clone for RoomMessageEventContent
sourcefn clone(&self) -> RoomMessageEventContent
fn clone(&self) -> RoomMessageEventContent
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for RoomMessageEventContent
impl Debug for RoomMessageEventContent
sourceimpl<'de> Deserialize<'de> for RoomMessageEventContent
impl<'de> Deserialize<'de> for RoomMessageEventContent
sourcefn deserialize<D>(
deserializer: D
) -> Result<RoomMessageEventContent, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<RoomMessageEventContent, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
sourceimpl EventContent for RoomMessageEventContent
impl EventContent for RoomMessageEventContent
type EventType = MessageLikeEventType
type EventType = MessageLikeEventType
sourcefn event_type(&self) -> <RoomMessageEventContent as EventContent>::EventType
fn event_type(&self) -> <RoomMessageEventContent as EventContent>::EventType
m.room.message
.sourceimpl From<AudioEventContent> for RoomMessageEventContent
impl From<AudioEventContent> for RoomMessageEventContent
sourcefn from(content: AudioEventContent) -> RoomMessageEventContent
fn from(content: AudioEventContent) -> RoomMessageEventContent
sourceimpl From<EmoteEventContent> for RoomMessageEventContent
impl From<EmoteEventContent> for RoomMessageEventContent
sourcefn from(content: EmoteEventContent) -> RoomMessageEventContent
fn from(content: EmoteEventContent) -> RoomMessageEventContent
sourceimpl From<FileEventContent> for RoomMessageEventContent
impl From<FileEventContent> for RoomMessageEventContent
sourcefn from(content: FileEventContent) -> RoomMessageEventContent
fn from(content: FileEventContent) -> RoomMessageEventContent
sourceimpl From<ImageEventContent> for RoomMessageEventContent
impl From<ImageEventContent> for RoomMessageEventContent
sourcefn from(content: ImageEventContent) -> RoomMessageEventContent
fn from(content: ImageEventContent) -> RoomMessageEventContent
sourceimpl From<LocationEventContent> for RoomMessageEventContent
impl From<LocationEventContent> for RoomMessageEventContent
sourcefn from(content: LocationEventContent) -> RoomMessageEventContent
fn from(content: LocationEventContent) -> RoomMessageEventContent
sourceimpl From<MessageEventContent> for RoomMessageEventContent
impl From<MessageEventContent> for RoomMessageEventContent
sourcefn from(content: MessageEventContent) -> RoomMessageEventContent
fn from(content: MessageEventContent) -> RoomMessageEventContent
sourceimpl From<MessageType> for RoomMessageEventContent
impl From<MessageType> for RoomMessageEventContent
sourcefn from(msgtype: MessageType) -> RoomMessageEventContent
fn from(msgtype: MessageType) -> RoomMessageEventContent
sourceimpl From<NoticeEventContent> for RoomMessageEventContent
impl From<NoticeEventContent> for RoomMessageEventContent
sourcefn from(content: NoticeEventContent) -> RoomMessageEventContent
fn from(content: NoticeEventContent) -> RoomMessageEventContent
sourceimpl From<RoomMessageEventContent> for AnyMessageLikeEventContent
impl From<RoomMessageEventContent> for AnyMessageLikeEventContent
sourcefn from(c: RoomMessageEventContent) -> AnyMessageLikeEventContent
fn from(c: RoomMessageEventContent) -> AnyMessageLikeEventContent
sourceimpl From<VideoEventContent> for RoomMessageEventContent
impl From<VideoEventContent> for RoomMessageEventContent
sourcefn from(content: VideoEventContent) -> RoomMessageEventContent
fn from(content: VideoEventContent) -> RoomMessageEventContent
sourceimpl From<VoiceEventContent> for RoomMessageEventContent
impl From<VoiceEventContent> for RoomMessageEventContent
sourcefn from(content: VoiceEventContent) -> RoomMessageEventContent
fn from(content: VoiceEventContent) -> RoomMessageEventContent
sourceimpl RedactContent for RoomMessageEventContent
impl RedactContent for RoomMessageEventContent
type Redacted = RedactedRoomMessageEventContent
type Redacted = RedactedRoomMessageEventContent
sourcefn redact(self, version: &RoomVersionId) -> RedactedRoomMessageEventContent
fn redact(self, version: &RoomVersionId) -> RedactedRoomMessageEventContent
self
into a redacted form (removing most or all fields) according to the spec. Read more