events: Add accessor methods for RoomMessageEventContent

This commit is contained in:
Jonas Platte 2021-11-23 10:50:14 +01:00
parent 897146e369
commit 1e9f846722
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
2 changed files with 14 additions and 0 deletions

View File

@ -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

View File

@ -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.