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)]
9#[serde(tag = "msgtype", rename = "m.server_notice")]
10pub struct ServerNoticeMessageEventContent {
11 pub body: String,
13
14 pub server_notice_type: ServerNoticeType,
16
17 #[serde(skip_serializing_if = "Option::is_none")]
21 pub admin_contact: Option<String>,
22
23 #[serde(skip_serializing_if = "Option::is_none")]
27 pub limit_type: Option<LimitType>,
28}
29
30impl ServerNoticeMessageEventContent {
31 pub fn new(body: String, server_notice_type: ServerNoticeType) -> Self {
33 Self { body, server_notice_type, admin_contact: None, limit_type: None }
34 }
35}
36
37#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
39#[derive(Clone, PartialEq, Eq, StringEnum)]
40#[non_exhaustive]
41pub enum ServerNoticeType {
42 #[ruma_enum(rename = "m.server_notice.usage_limit_reached")]
44 UsageLimitReached,
45
46 #[doc(hidden)]
47 _Custom(PrivOwnedStr),
48}
49
50#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
52#[derive(Clone, PartialEq, Eq, StringEnum)]
53#[ruma_enum(rename_all = "snake_case")]
54#[non_exhaustive]
55pub enum LimitType {
56 MonthlyActiveUser,
61
62 #[doc(hidden)]
63 _Custom(PrivOwnedStr),
64}