1use std::fmt;
6
7use ruma_macros::EventContent;
8use serde::{
9 de::{self, Deserialize, Deserializer},
10 ser::{Serialize, SerializeStruct as _, Serializer},
11};
12
13#[derive(Clone, Debug, Default, EventContent)]
25#[allow(clippy::exhaustive_structs)]
26#[ruma_event(type = "m.dummy", kind = ToDevice)]
27pub struct ToDeviceDummyEventContent;
28
29impl ToDeviceDummyEventContent {
30 pub fn new() -> Self {
32 Self
33 }
34}
35
36impl<'de> Deserialize<'de> for ToDeviceDummyEventContent {
37 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
38 where
39 D: Deserializer<'de>,
40 {
41 struct Visitor;
42
43 impl<'de> de::Visitor<'de> for Visitor {
44 type Value = ToDeviceDummyEventContent;
45
46 fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
47 formatter.write_str("a struct")
48 }
49
50 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
51 where
52 A: de::MapAccess<'de>,
53 {
54 while map.next_entry::<de::IgnoredAny, de::IgnoredAny>()?.is_some() {}
55 Ok(ToDeviceDummyEventContent)
56 }
57 }
58
59 deserializer.deserialize_struct("ToDeviceDummyEventContent", &[], Visitor)
60 }
61}
62
63impl Serialize for ToDeviceDummyEventContent {
64 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
65 where
66 S: Serializer,
67 {
68 serializer.serialize_struct("ToDeviceDummyEventContent", 0)?.end()
69 }
70}