From 76c2f5c449c12bb1629ccb2c07ae99fe7a0abb93 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Sat, 25 Jul 2020 01:44:06 +0200 Subject: [PATCH] Add a convenience constructor to FormattedBody --- ruma-events/src/room/message.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ruma-events/src/room/message.rs b/ruma-events/src/room/message.rs index 1f35f585..a28ba635 100644 --- a/ruma-events/src/room/message.rs +++ b/ruma-events/src/room/message.rs @@ -292,6 +292,13 @@ pub struct FormattedBody { pub body: String, } +impl FormattedBody { + /// Creates a new HTML-formatted message body. + pub fn html(body: String) -> Self { + Self { format: MessageFormat::Html, body } + } +} + /// The payload for a text message. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct TextMessageEventContent {