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