ruwuma/ruma-events/src/room/join_rules.rs
Ragotzy.devin 5e428ac95a
Add support for redacted events
* Generate redacted event enums and implement corresponding event structs
* Enable the *EventContent derives to generate redacted events

  Most redacted event code is now generated by the *EventContent derive
  macro. The exception are any content structs with the custom_redaction
  attribute. This leaves implementing up to the user.
* Add redact method to Redaction/CustomEventContent
* Add accessor methods for redacted event enums
* Add RedactedEventContent trait and super traits to match EventContent
2020-07-11 14:59:36 +02:00

40 lines
1.2 KiB
Rust

//! Types for the *m.room.join_rules* event.
use ruma_events_macros::StateEventContent;
use serde::{Deserialize, Serialize};
use strum::{Display, EnumString};
use crate::StateEvent;
/// Describes how users are allowed to join the room.
pub type JoinRulesEvent = StateEvent<JoinRulesEventContent>;
/// The payload for `JoinRulesEvent`.
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
#[ruma_event(type = "m.room.join_rules")]
pub struct JoinRulesEventContent {
/// The type of rules used for users wishing to join this room.
#[ruma_event(skip_redaction)]
pub join_rule: JoinRule,
}
/// The rule used for users wishing to join this room.
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
#[non_exhaustive]
#[serde(rename_all = "lowercase")]
#[strum(serialize_all = "lowercase")]
pub enum JoinRule {
/// A user who wishes to join the room must first receive an invite to the room from someone
/// already inside of the room.
Invite,
/// Reserved but not yet implemented by the Matrix specification.
Knock,
/// Reserved but not yet implemented by the Matrix specification.
Private,
/// Anyone can join the room without any prior action.
Public,
}