ruma_events/policy/rule/
server.rs1use ruma_common::room_version_rules::RedactionRules;
6use ruma_macros::EventContent;
7use serde::{Deserialize, Serialize};
8
9use super::{PolicyRuleEventContent, PossiblyRedactedPolicyRuleEventContent};
10use crate::{PossiblyRedactedStateEventContent, RedactContent, StateEventType, StaticEventContent};
11
12#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
16#[allow(clippy::exhaustive_structs)]
17#[ruma_event(type = "m.policy.rule.server", kind = State, state_key_type = String, custom_possibly_redacted)]
18pub struct PolicyRuleServerEventContent(pub PolicyRuleEventContent);
19
20#[derive(Clone, Debug, Deserialize, Serialize)]
24#[allow(clippy::exhaustive_structs)]
25pub struct PossiblyRedactedPolicyRuleServerEventContent(pub PossiblyRedactedPolicyRuleEventContent);
26
27impl PossiblyRedactedStateEventContent for PossiblyRedactedPolicyRuleServerEventContent {
28 type StateKey = String;
29
30 fn event_type(&self) -> StateEventType {
31 StateEventType::PolicyRuleServer
32 }
33}
34
35impl StaticEventContent for PossiblyRedactedPolicyRuleServerEventContent {
36 const TYPE: &'static str = PolicyRuleServerEventContent::TYPE;
37 type IsPrefix = <PolicyRuleServerEventContent as StaticEventContent>::IsPrefix;
38}
39
40impl RedactContent for PossiblyRedactedPolicyRuleServerEventContent {
41 type Redacted = Self;
42
43 fn redact(self, _rules: &RedactionRules) -> Self::Redacted {
44 Self(PossiblyRedactedPolicyRuleEventContent::empty())
45 }
46}
47
48impl From<PolicyRuleServerEventContent> for PossiblyRedactedPolicyRuleServerEventContent {
49 fn from(value: PolicyRuleServerEventContent) -> Self {
50 let PolicyRuleServerEventContent(policy) = value;
51 Self(policy.into())
52 }
53}
54
55impl From<RedactedPolicyRuleServerEventContent> for PossiblyRedactedPolicyRuleServerEventContent {
56 fn from(value: RedactedPolicyRuleServerEventContent) -> Self {
57 let RedactedPolicyRuleServerEventContent {} = value;
58 Self(PossiblyRedactedPolicyRuleEventContent::empty())
59 }
60}