@@ -33,36 +33,42 @@ pub enum StateTestEvent {
33
33
Custom ( JsonValue ) ,
34
34
}
35
35
36
- impl StateTestEvent {
37
- /// Get the JSON representation of this test event.
38
- pub fn into_json_value ( self ) -> JsonValue {
39
- match self {
40
- Self :: Alias => test_json:: sync_events:: ALIAS . to_owned ( ) ,
41
- Self :: Aliases => test_json:: sync_events:: ALIASES . to_owned ( ) ,
42
- Self :: Create => test_json:: sync_events:: CREATE . to_owned ( ) ,
43
- Self :: Encryption => test_json:: sync_events:: ENCRYPTION . to_owned ( ) ,
44
- Self :: HistoryVisibility => test_json:: sync_events:: HISTORY_VISIBILITY . to_owned ( ) ,
45
- Self :: JoinRules => test_json:: sync_events:: JOIN_RULES . to_owned ( ) ,
46
- Self :: Member => test_json:: sync_events:: MEMBER . to_owned ( ) ,
47
- Self :: MemberAdditional => test_json:: sync_events:: MEMBER_ADDITIONAL . to_owned ( ) ,
48
- Self :: MemberBan => test_json:: sync_events:: MEMBER_BAN . to_owned ( ) ,
49
- Self :: MemberInvite => test_json:: sync_events:: MEMBER_INVITE . to_owned ( ) ,
50
- Self :: MemberLeave => test_json:: sync_events:: MEMBER_LEAVE . to_owned ( ) ,
51
- Self :: MemberNameChange => test_json:: sync_events:: MEMBER_NAME_CHANGE . to_owned ( ) ,
52
- Self :: PowerLevels => test_json:: sync_events:: POWER_LEVELS . to_owned ( ) ,
53
- Self :: RedactedInvalid => test_json:: sync_events:: REDACTED_INVALID . to_owned ( ) ,
54
- Self :: RedactedState => test_json:: sync_events:: REDACTED_STATE . to_owned ( ) ,
55
- Self :: RoomAvatar => test_json:: sync_events:: ROOM_AVATAR . to_owned ( ) ,
56
- Self :: RoomName => test_json:: sync_events:: NAME . to_owned ( ) ,
57
- Self :: RoomPinnedEvents => test_json:: sync_events:: PINNED_EVENTS . to_owned ( ) ,
58
- Self :: RoomTopic => test_json:: sync_events:: TOPIC . to_owned ( ) ,
59
- Self :: Custom ( json) => json,
36
+ impl From < StateTestEvent > for JsonValue {
37
+ fn from ( val : StateTestEvent ) -> Self {
38
+ match val {
39
+ StateTestEvent :: Alias => test_json:: sync_events:: ALIAS . to_owned ( ) ,
40
+ StateTestEvent :: Aliases => test_json:: sync_events:: ALIASES . to_owned ( ) ,
41
+ StateTestEvent :: Create => test_json:: sync_events:: CREATE . to_owned ( ) ,
42
+ StateTestEvent :: Encryption => test_json:: sync_events:: ENCRYPTION . to_owned ( ) ,
43
+ StateTestEvent :: HistoryVisibility => {
44
+ test_json:: sync_events:: HISTORY_VISIBILITY . to_owned ( )
45
+ }
46
+ StateTestEvent :: JoinRules => test_json:: sync_events:: JOIN_RULES . to_owned ( ) ,
47
+ StateTestEvent :: Member => test_json:: sync_events:: MEMBER . to_owned ( ) ,
48
+ StateTestEvent :: MemberAdditional => {
49
+ test_json:: sync_events:: MEMBER_ADDITIONAL . to_owned ( )
50
+ }
51
+ StateTestEvent :: MemberBan => test_json:: sync_events:: MEMBER_BAN . to_owned ( ) ,
52
+ StateTestEvent :: MemberInvite => test_json:: sync_events:: MEMBER_INVITE . to_owned ( ) ,
53
+ StateTestEvent :: MemberLeave => test_json:: sync_events:: MEMBER_LEAVE . to_owned ( ) ,
54
+ StateTestEvent :: MemberNameChange => {
55
+ test_json:: sync_events:: MEMBER_NAME_CHANGE . to_owned ( )
56
+ }
57
+ StateTestEvent :: PowerLevels => test_json:: sync_events:: POWER_LEVELS . to_owned ( ) ,
58
+ StateTestEvent :: RedactedInvalid => test_json:: sync_events:: REDACTED_INVALID . to_owned ( ) ,
59
+ StateTestEvent :: RedactedState => test_json:: sync_events:: REDACTED_STATE . to_owned ( ) ,
60
+ StateTestEvent :: RoomAvatar => test_json:: sync_events:: ROOM_AVATAR . to_owned ( ) ,
61
+ StateTestEvent :: RoomName => test_json:: sync_events:: NAME . to_owned ( ) ,
62
+ StateTestEvent :: RoomPinnedEvents => test_json:: sync_events:: PINNED_EVENTS . to_owned ( ) ,
63
+ StateTestEvent :: RoomTopic => test_json:: sync_events:: TOPIC . to_owned ( ) ,
64
+ StateTestEvent :: Custom ( json) => json,
60
65
}
61
66
}
67
+ }
62
68
63
- /// Get the typed JSON representation of this test event.
64
- pub fn into_raw_event ( self ) -> Raw < AnySyncStateEvent > {
65
- from_json_value ( self . into_json_value ( ) ) . unwrap ( )
69
+ impl From < StateTestEvent > for Raw < AnySyncStateEvent > {
70
+ fn from ( val : StateTestEvent ) -> Self {
71
+ from_json_value ( val . into ( ) ) . unwrap ( )
66
72
}
67
73
}
68
74
@@ -73,19 +79,19 @@ pub enum StrippedStateTestEvent {
73
79
Custom ( JsonValue ) ,
74
80
}
75
81
76
- impl StrippedStateTestEvent {
77
- /// Get the JSON representation of this test event.
78
- pub fn into_json_value ( self ) -> JsonValue {
79
- match self {
80
- Self :: Member => test_json:: sync_events:: MEMBER_STRIPPED . to_owned ( ) ,
81
- Self :: RoomName => test_json:: sync_events:: NAME_STRIPPED . to_owned ( ) ,
82
- Self :: Custom ( json) => json,
82
+ impl From < StrippedStateTestEvent > for JsonValue {
83
+ fn from ( val : StrippedStateTestEvent ) -> Self {
84
+ match val {
85
+ StrippedStateTestEvent :: Member => test_json:: sync_events:: MEMBER_STRIPPED . to_owned ( ) ,
86
+ StrippedStateTestEvent :: RoomName => test_json:: sync_events:: NAME_STRIPPED . to_owned ( ) ,
87
+ StrippedStateTestEvent :: Custom ( json) => json,
83
88
}
84
89
}
90
+ }
85
91
86
- /// Get the typed JSON representation of this test event.
87
- pub fn into_raw_event ( self ) -> Raw < AnyStrippedStateEvent > {
88
- from_json_value ( self . into_json_value ( ) ) . unwrap ( )
92
+ impl From < StrippedStateTestEvent > for Raw < AnyStrippedStateEvent > {
93
+ fn from ( val : StrippedStateTestEvent ) -> Self {
94
+ from_json_value ( val . into ( ) ) . unwrap ( )
89
95
}
90
96
}
91
97
@@ -96,19 +102,19 @@ pub enum RoomAccountDataTestEvent {
96
102
Custom ( JsonValue ) ,
97
103
}
98
104
99
- impl RoomAccountDataTestEvent {
100
- /// Get the JSON representation of this test event.
101
- pub fn into_json_value ( self ) -> JsonValue {
102
- match self {
103
- Self :: FullyRead => test_json:: sync_events:: FULLY_READ . to_owned ( ) ,
104
- Self :: Tags => test_json:: sync_events:: TAG . to_owned ( ) ,
105
- Self :: Custom ( json) => json,
105
+ impl From < RoomAccountDataTestEvent > for JsonValue {
106
+ fn from ( val : RoomAccountDataTestEvent ) -> Self {
107
+ match val {
108
+ RoomAccountDataTestEvent :: FullyRead => test_json:: sync_events:: FULLY_READ . to_owned ( ) ,
109
+ RoomAccountDataTestEvent :: Tags => test_json:: sync_events:: TAG . to_owned ( ) ,
110
+ RoomAccountDataTestEvent :: Custom ( json) => json,
106
111
}
107
112
}
113
+ }
108
114
109
- /// Get the typed JSON representation of this test event.
110
- pub fn into_raw_event ( self ) -> Raw < AnyRoomAccountDataEvent > {
111
- from_json_value ( self . into_json_value ( ) ) . unwrap ( )
115
+ impl From < RoomAccountDataTestEvent > for Raw < AnyRoomAccountDataEvent > {
116
+ fn from ( val : RoomAccountDataTestEvent ) -> Self {
117
+ from_json_value ( val . into ( ) ) . unwrap ( )
112
118
}
113
119
}
114
120
@@ -118,18 +124,18 @@ pub enum PresenceTestEvent {
118
124
Custom ( JsonValue ) ,
119
125
}
120
126
121
- impl PresenceTestEvent {
122
- /// Get the JSON representation of this test event.
123
- pub fn into_json_value ( self ) -> JsonValue {
124
- match self {
125
- Self :: Presence => test_json:: sync_events:: PRESENCE . to_owned ( ) ,
126
- Self :: Custom ( json) => json,
127
+ impl From < PresenceTestEvent > for JsonValue {
128
+ fn from ( val : PresenceTestEvent ) -> Self {
129
+ match val {
130
+ PresenceTestEvent :: Presence => test_json:: sync_events:: PRESENCE . to_owned ( ) ,
131
+ PresenceTestEvent :: Custom ( json) => json,
127
132
}
128
133
}
134
+ }
129
135
130
- /// Get the typed JSON representation of this test event.
131
- pub fn into_raw_event ( self ) -> Raw < PresenceEvent > {
132
- from_json_value ( self . into_json_value ( ) ) . unwrap ( )
136
+ impl From < PresenceTestEvent > for Raw < PresenceEvent > {
137
+ fn from ( val : PresenceTestEvent ) -> Self {
138
+ from_json_value ( val . into ( ) ) . unwrap ( )
133
139
}
134
140
}
135
141
@@ -140,18 +146,18 @@ pub enum GlobalAccountDataTestEvent {
140
146
Custom ( JsonValue ) ,
141
147
}
142
148
143
- impl GlobalAccountDataTestEvent {
144
- /// Get the JSON representation of this test event.
145
- pub fn into_json_value ( self ) -> JsonValue {
146
- match self {
147
- Self :: Direct => test_json:: sync_events:: DIRECT . to_owned ( ) ,
148
- Self :: PushRules => test_json:: sync_events:: PUSH_RULES . to_owned ( ) ,
149
- Self :: Custom ( json) => json,
149
+ impl From < GlobalAccountDataTestEvent > for JsonValue {
150
+ fn from ( val : GlobalAccountDataTestEvent ) -> Self {
151
+ match val {
152
+ GlobalAccountDataTestEvent :: Direct => test_json:: sync_events:: DIRECT . to_owned ( ) ,
153
+ GlobalAccountDataTestEvent :: PushRules => test_json:: sync_events:: PUSH_RULES . to_owned ( ) ,
154
+ GlobalAccountDataTestEvent :: Custom ( json) => json,
150
155
}
151
156
}
157
+ }
152
158
153
- /// Get the typed JSON representation of this test event.
154
- pub fn into_raw_event ( self ) -> Raw < AnyGlobalAccountDataEvent > {
155
- from_json_value ( self . into_json_value ( ) ) . unwrap ( )
159
+ impl From < GlobalAccountDataTestEvent > for Raw < AnyGlobalAccountDataEvent > {
160
+ fn from ( val : GlobalAccountDataTestEvent ) -> Self {
161
+ from_json_value ( val . into ( ) ) . unwrap ( )
156
162
}
157
163
}
0 commit comments