events: Make text & notice message event content non-exhaustive

This commit is contained in:
Jonas Platte 2020-11-25 18:37:51 +01:00
parent d519a47a00
commit 199f5840dd
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
2 changed files with 4 additions and 11 deletions

View File

@ -3,10 +3,7 @@ use std::{convert::TryFrom, env, process::exit};
use http::Uri;
use ruma::{
api::client::r0::{alias::get_alias, membership::join_room_by_id, message::send_message_event},
events::{
room::message::{MessageEventContent, TextMessageEventContent},
AnyMessageEventContent,
},
events::{room::message::MessageEventContent, AnyMessageEventContent},
RoomAliasId,
};
use ruma_client::{self, Client};
@ -21,13 +18,7 @@ async fn hello_world(homeserver_url: Uri, room_alias: &RoomAliasId) -> anyhow::R
.request(send_message_event::Request::new(
&room_id,
"1",
&AnyMessageEventContent::RoomMessage(MessageEventContent::Text(
TextMessageEventContent {
body: "Hello World!".to_owned(),
formatted: None,
relates_to: None,
},
)),
&AnyMessageEventContent::RoomMessage(MessageEventContent::text_plain("Hello World!")),
))
.await?;

View File

@ -299,6 +299,7 @@ pub struct LocationInfo {
/// The payload for a notice message.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct NoticeMessageEventContent {
/// The notice text to send.
pub body: String,
@ -419,6 +420,7 @@ impl FormattedBody {
/// The payload for a text message.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct TextMessageEventContent {
/// The body of the message.
pub body: String,