ruma_events/room/
tombstone.rs1use ruma_common::OwnedRoomId;
6use ruma_macros::EventContent;
7use serde::{Deserialize, Serialize};
8
9use crate::{EmptyStateKey, PossiblyRedactedStateEventContent, StateEventType, StaticEventContent};
10
11#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
16#[ruma_event(
17 type = "m.room.tombstone",
18 kind = State,
19 state_key_type = EmptyStateKey,
20 custom_possibly_redacted,
21)]
22#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
23pub struct RoomTombstoneEventContent {
24 #[cfg_attr(feature = "compat-optional", serde(default))]
29 pub body: String,
30
31 pub replacement_room: OwnedRoomId,
33}
34
35impl RoomTombstoneEventContent {
36 pub fn new(body: String, replacement_room: OwnedRoomId) -> Self {
38 Self { body, replacement_room }
39 }
40}
41
42#[derive(Clone, Debug, Deserialize, Serialize)]
46#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
47pub struct PossiblyRedactedRoomTombstoneEventContent {
48 pub body: Option<String>,
50
51 pub replacement_room: Option<OwnedRoomId>,
53}
54
55impl PossiblyRedactedStateEventContent for PossiblyRedactedRoomTombstoneEventContent {
56 type StateKey = EmptyStateKey;
57
58 fn event_type(&self) -> StateEventType {
59 StateEventType::RoomTombstone
60 }
61}
62
63impl StaticEventContent for PossiblyRedactedRoomTombstoneEventContent {
64 const TYPE: &'static str = RoomTombstoneEventContent::TYPE;
65 type IsPrefix = <RoomTombstoneEventContent as StaticEventContent>::IsPrefix;
66}