ruma_events/policy/
rule.rs1use ruma_common::serde::StringEnum;
4use serde::{Deserialize, Serialize};
5
6use crate::PrivOwnedStr;
7
8pub mod room;
9pub mod server;
10pub mod user;
11
12#[derive(Clone, Debug, Deserialize, Serialize)]
14#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
15pub struct PolicyRuleEventContent {
16 pub entity: String,
21
22 pub recommendation: Recommendation,
24
25 pub reason: String,
27}
28
29impl PolicyRuleEventContent {
30 pub fn new(entity: String, recommendation: Recommendation, reason: String) -> Self {
32 Self { entity, recommendation, reason }
33 }
34}
35
36#[derive(Clone, Debug, Deserialize, Serialize)]
40#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
41pub struct PossiblyRedactedPolicyRuleEventContent {
42 #[serde(skip_serializing_if = "Option::is_none")]
47 pub entity: Option<String>,
48
49 #[serde(skip_serializing_if = "Option::is_none")]
51 pub recommendation: Option<Recommendation>,
52
53 #[serde(skip_serializing_if = "Option::is_none")]
55 pub reason: Option<String>,
56}
57
58#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
60#[derive(Clone, PartialEq, Eq, StringEnum)]
61#[non_exhaustive]
62pub enum Recommendation {
63 #[ruma_enum(rename = "m.ban")]
65 Ban,
66
67 #[doc(hidden)]
68 _Custom(PrivOwnedStr),
69}