ruma_events/room/message/
server_notice.rs1use ruma_common::serde::StringEnum;
2use serde::{Deserialize, Serialize};
3
4use crate::PrivOwnedStr;
5
6#[derive(Clone, Debug, Deserialize, Serialize)]
8#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
9pub struct ServerNoticeMessageEventContent {
10 pub body: String,
12
13 pub server_notice_type: ServerNoticeType,
15
16 #[serde(skip_serializing_if = "Option::is_none")]
20 pub admin_contact: Option<String>,
21
22 #[serde(skip_serializing_if = "Option::is_none")]
26 pub limit_type: Option<LimitType>,
27}
28
29impl ServerNoticeMessageEventContent {
30 pub fn new(body: String, server_notice_type: ServerNoticeType) -> Self {
32 Self { body, server_notice_type, admin_contact: None, limit_type: None }
33 }
34}
35
36#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
38#[derive(Clone, PartialEq, Eq, StringEnum)]
39#[non_exhaustive]
40pub enum ServerNoticeType {
41 #[ruma_enum(rename = "m.server_notice.usage_limit_reached")]
43 UsageLimitReached,
44
45 #[doc(hidden)]
46 _Custom(PrivOwnedStr),
47}
48
49#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
51#[derive(Clone, PartialEq, Eq, StringEnum)]
52#[ruma_enum(rename_all = "snake_case")]
53#[non_exhaustive]
54pub enum LimitType {
55 MonthlyActiveUser,
60
61 #[doc(hidden)]
62 _Custom(PrivOwnedStr),
63}