ruma_events/room/message/
emote.rsuse serde::{Deserialize, Serialize};
use super::FormattedBody;
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
#[serde(tag = "msgtype", rename = "m.emote")]
pub struct EmoteMessageEventContent {
pub body: String,
#[serde(flatten)]
pub formatted: Option<FormattedBody>,
}
impl EmoteMessageEventContent {
pub fn plain(body: impl Into<String>) -> Self {
let body = body.into();
Self { body, formatted: None }
}
pub fn html(body: impl Into<String>, html_body: impl Into<String>) -> Self {
let body = body.into();
Self { body, formatted: Some(FormattedBody::html(html_body)) }
}
#[cfg(feature = "markdown")]
pub fn markdown(body: impl AsRef<str> + Into<String>) -> Self {
if let Some(formatted) = FormattedBody::markdown(&body) {
Self::html(body, formatted.body)
} else {
Self::plain(body)
}
}
}