use ruma_common::serde::StringEnum;
use serde::{Deserialize, Serialize};
use crate::PrivOwnedStr;
pub mod room;
pub mod server;
pub mod user;
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
pub struct PolicyRuleEventContent {
pub entity: String,
pub recommendation: Recommendation,
pub reason: String,
}
impl PolicyRuleEventContent {
pub fn new(entity: String, recommendation: Recommendation, reason: String) -> Self {
Self { entity, recommendation, reason }
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
pub struct PossiblyRedactedPolicyRuleEventContent {
#[serde(skip_serializing_if = "Option::is_none")]
pub entity: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub recommendation: Option<Recommendation>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<String>,
}
impl PossiblyRedactedPolicyRuleEventContent {
pub fn new(entity: String, recommendation: Recommendation, reason: String) -> Self {
Self { entity: Some(entity), recommendation: Some(recommendation), reason: Some(reason) }
}
pub(crate) fn empty() -> Self {
Self { entity: None, recommendation: None, reason: None }
}
}
impl From<PolicyRuleEventContent> for PossiblyRedactedPolicyRuleEventContent {
fn from(value: PolicyRuleEventContent) -> Self {
let PolicyRuleEventContent { entity, recommendation, reason } = value;
Self { entity: Some(entity), recommendation: Some(recommendation), reason: Some(reason) }
}
}
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, StringEnum)]
#[non_exhaustive]
pub enum Recommendation {
#[ruma_enum(rename = "m.ban")]
Ban,
#[doc(hidden)]
_Custom(PrivOwnedStr),
}