diff --git a/crates/ruma-events/CHANGELOG.md b/crates/ruma-events/CHANGELOG.md index 3b119a06..90dd8f99 100644 --- a/crates/ruma-events/CHANGELOG.md +++ b/crates/ruma-events/CHANGELOG.md @@ -16,6 +16,7 @@ Improvements: * Add `room::message::MessageType::body` accessor method * Implement `Redact` for event structs (in addition to `Any` event enums) +* Add `room::message::RoomMessageEventContent::{body, msgtype}` accessor methods # 0.24.6 diff --git a/crates/ruma-events/src/room/message.rs b/crates/ruma-events/src/room/message.rs index 08f4930c..30a077d4 100644 --- a/crates/ruma-events/src/room/message.rs +++ b/crates/ruma-events/src/room/message.rs @@ -164,6 +164,19 @@ impl RoomMessageEventContent { ..Self::notice_html(body, html_body) } } + + /// 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. + pub fn msgtype(&self) -> &str { + self.msgtype.msgtype() + } + + /// Return a reference to the message body. + pub fn body(&self) -> &str { + self.msgtype.body() + } } /// The content that is specific to each message type variant.