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