ruma_events/room/
tombstone.rs1use ruma_common::OwnedRoomId;
6use ruma_macros::EventContent;
7use serde::{Deserialize, Serialize};
8
9use crate::{
10 EmptyStateKey, EventContent, PossiblyRedactedStateEventContent, StateEventType,
11 StaticEventContent,
12};
13
14#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
19#[ruma_event(
20 type = "m.room.tombstone",
21 kind = State,
22 state_key_type = EmptyStateKey,
23 custom_possibly_redacted,
24)]
25#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
26pub struct RoomTombstoneEventContent {
27 #[cfg_attr(feature = "compat-optional", serde(default))]
32 pub body: String,
33
34 pub replacement_room: OwnedRoomId,
36}
37
38impl RoomTombstoneEventContent {
39 pub fn new(body: String, replacement_room: OwnedRoomId) -> Self {
41 Self { body, replacement_room }
42 }
43}
44
45#[derive(Clone, Debug, Deserialize, Serialize)]
49#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
50pub struct PossiblyRedactedRoomTombstoneEventContent {
51 pub body: Option<String>,
53
54 pub replacement_room: Option<OwnedRoomId>,
56}
57
58impl EventContent for PossiblyRedactedRoomTombstoneEventContent {
59 type EventType = StateEventType;
60
61 fn event_type(&self) -> Self::EventType {
62 StateEventType::RoomTombstone
63 }
64}
65
66impl PossiblyRedactedStateEventContent for PossiblyRedactedRoomTombstoneEventContent {
67 type StateKey = EmptyStateKey;
68}
69
70impl StaticEventContent for PossiblyRedactedRoomTombstoneEventContent {
71 const TYPE: &'static str = "m.room.tombstone";
72}