ruma_events/policy/rule/
user.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.user", kind = State, state_key_type = String, custom_possibly_redacted)]
18pub struct PolicyRuleUserEventContent(pub PolicyRuleEventContent);
19
20#[derive(Clone, Debug, Deserialize, Serialize)]
24#[allow(clippy::exhaustive_structs)]
25pub struct PossiblyRedactedPolicyRuleUserEventContent(pub PossiblyRedactedPolicyRuleEventContent);
26
27impl PossiblyRedactedStateEventContent for PossiblyRedactedPolicyRuleUserEventContent {
28 type StateKey = String;
29
30 fn event_type(&self) -> StateEventType {
31 StateEventType::PolicyRuleUser
32 }
33}
34
35impl StaticEventContent for PossiblyRedactedPolicyRuleUserEventContent {
36 const TYPE: &'static str = PolicyRuleUserEventContent::TYPE;
37 type IsPrefix = <PolicyRuleUserEventContent as StaticEventContent>::IsPrefix;
38}
39
40impl RedactContent for PossiblyRedactedPolicyRuleUserEventContent {
41 type Redacted = Self;
42
43 fn redact(self, _rules: &RedactionRules) -> Self::Redacted {
44 Self(PossiblyRedactedPolicyRuleEventContent::empty())
45 }
46}
47
48impl From<PolicyRuleUserEventContent> for PossiblyRedactedPolicyRuleUserEventContent {
49 fn from(value: PolicyRuleUserEventContent) -> Self {
50 let PolicyRuleUserEventContent(policy) = value;
51 Self(policy.into())
52 }
53}
54
55impl From<RedactedPolicyRuleUserEventContent> for PossiblyRedactedPolicyRuleUserEventContent {
56 fn from(value: RedactedPolicyRuleUserEventContent) -> Self {
57 let RedactedPolicyRuleUserEventContent {} = value;
58 Self(PossiblyRedactedPolicyRuleEventContent::empty())
59 }
60}