ruma_events/room/
avatar.rs1use js_int::UInt;
6#[cfg(feature = "unstable-msc2448")]
7use ruma_common::serde::Base64;
8use ruma_common::OwnedMxcUri;
9use ruma_macros::EventContent;
10use serde::{Deserialize, Serialize};
11
12use super::ThumbnailInfo;
13use crate::EmptyStateKey;
14
15#[derive(Clone, Debug, Default, Deserialize, Serialize, EventContent)]
21#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
22#[ruma_event(type = "m.room.avatar", kind = State, state_key_type = EmptyStateKey)]
23pub struct RoomAvatarEventContent {
24 #[serde(skip_serializing_if = "Option::is_none")]
26 pub info: Option<Box<ImageInfo>>,
27
28 pub url: Option<OwnedMxcUri>,
30}
31
32impl RoomAvatarEventContent {
33 pub fn new() -> Self {
35 Self::default()
36 }
37}
38
39#[derive(Clone, Debug, Default, Deserialize, Serialize)]
41#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
42pub struct ImageInfo {
43 #[serde(rename = "h", skip_serializing_if = "Option::is_none")]
45 pub height: Option<UInt>,
46
47 #[serde(rename = "w", skip_serializing_if = "Option::is_none")]
49 pub width: Option<UInt>,
50
51 #[serde(skip_serializing_if = "Option::is_none")]
53 pub mimetype: Option<String>,
54
55 #[serde(skip_serializing_if = "Option::is_none")]
57 pub size: Option<UInt>,
58
59 #[serde(skip_serializing_if = "Option::is_none")]
61 pub thumbnail_info: Option<Box<ThumbnailInfo>>,
62
63 #[serde(skip_serializing_if = "Option::is_none")]
65 pub thumbnail_url: Option<OwnedMxcUri>,
66
67 #[cfg(feature = "unstable-msc2448")]
72 #[serde(rename = "xyz.amorgan.blurhash", skip_serializing_if = "Option::is_none")]
73 pub blurhash: Option<String>,
74
75 #[cfg(feature = "unstable-msc2448")]
80 #[serde(rename = "xyz.amorgan.thumbhash", skip_serializing_if = "Option::is_none")]
81 pub thumbhash: Option<Base64>,
82}
83
84impl ImageInfo {
85 pub fn new() -> Self {
87 Self::default()
88 }
89}