Skip to main content

ruma_events/image_pack/
rooms.rs

1//! Types for the `m.image_pack.rooms` account data.
2
3use std::collections::BTreeMap;
4
5use ruma_common::OwnedRoomId;
6use ruma_macros::EventContent;
7use serde::{Deserialize, Serialize};
8
9/// The content of an `m.image_pack.rooms` event.
10#[derive(Clone, Debug, Default, Deserialize, Serialize, EventContent)]
11#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
12#[ruma_event(type = "m.image_pack.rooms", kind = GlobalAccountData)]
13pub struct ImagePackRoomsEventContent {
14    /// A map of room ID to a map of state key to an empty object.
15    ///
16    /// Each entry references a specific `m.room.image_pack` state event that the user has enabled
17    /// globally.
18    pub rooms: BTreeMap<OwnedRoomId, BTreeMap<String, RoomImagePackMeta>>,
19}
20
21impl ImagePackRoomsEventContent {
22    /// Creates a new `ImagePackRoomsEventContent` with the given map of enabled image packs in each
23    /// room.
24    pub fn new(rooms: BTreeMap<OwnedRoomId, BTreeMap<String, RoomImagePackMeta>>) -> Self {
25        Self { rooms }
26    }
27}
28
29/// Additional metadata for a globally enabled room image pack.
30///
31/// This is currently empty.
32#[derive(Clone, Debug, Default, Deserialize, Serialize)]
33#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
34pub struct RoomImagePackMeta {}
35
36impl RoomImagePackMeta {
37    /// Creates a new empty `RoomImagePackMeta`.
38    pub fn new() -> Self {
39        Self {}
40    }
41}