@@ -33,36 +33,42 @@ pub enum StateTestEvent {
3333 Custom ( JsonValue ) ,
3434}
3535
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,
6065 }
6166 }
67+ }
6268
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 ( )
6672 }
6773}
6874
@@ -73,19 +79,19 @@ pub enum StrippedStateTestEvent {
7379 Custom ( JsonValue ) ,
7480}
7581
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,
8388 }
8489 }
90+ }
8591
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 ( )
8995 }
9096}
9197
@@ -97,20 +103,22 @@ pub enum RoomAccountDataTestEvent {
97103 Custom ( JsonValue ) ,
98104}
99105
100- impl RoomAccountDataTestEvent {
101- /// Get the JSON representation of this test event.
102- pub fn into_json_value ( self ) -> JsonValue {
103- match self {
104- Self :: FullyRead => test_json:: sync_events:: FULLY_READ . to_owned ( ) ,
105- Self :: Tags => test_json:: sync_events:: TAG . to_owned ( ) ,
106- Self :: MarkedUnread => test_json:: sync_events:: MARKED_UNREAD . to_owned ( ) ,
107- Self :: Custom ( json) => json,
106+ impl From < RoomAccountDataTestEvent > for JsonValue {
107+ fn from ( val : RoomAccountDataTestEvent ) -> Self {
108+ match val {
109+ RoomAccountDataTestEvent :: FullyRead => test_json:: sync_events:: FULLY_READ . to_owned ( ) ,
110+ RoomAccountDataTestEvent :: Tags => test_json:: sync_events:: TAG . to_owned ( ) ,
111+ RoomAccountDataTestEvent :: MarkedUnread => {
112+ test_json:: sync_events:: MARKED_UNREAD . to_owned ( )
113+ }
114+ RoomAccountDataTestEvent :: Custom ( json) => json,
108115 }
109116 }
117+ }
110118
111- /// Get the typed JSON representation of this test event.
112- pub fn into_raw_event ( self ) -> Raw < AnyRoomAccountDataEvent > {
113- from_json_value ( self . into_json_value ( ) ) . unwrap ( )
119+ impl From < RoomAccountDataTestEvent > for Raw < AnyRoomAccountDataEvent > {
120+ fn from ( val : RoomAccountDataTestEvent ) -> Self {
121+ from_json_value ( val . into ( ) ) . unwrap ( )
114122 }
115123}
116124
@@ -120,18 +128,18 @@ pub enum PresenceTestEvent {
120128 Custom ( JsonValue ) ,
121129}
122130
123- impl PresenceTestEvent {
124- /// Get the JSON representation of this test event.
125- pub fn into_json_value ( self ) -> JsonValue {
126- match self {
127- Self :: Presence => test_json:: sync_events:: PRESENCE . to_owned ( ) ,
128- Self :: Custom ( json) => json,
131+ impl From < PresenceTestEvent > for JsonValue {
132+ fn from ( val : PresenceTestEvent ) -> Self {
133+ match val {
134+ PresenceTestEvent :: Presence => test_json:: sync_events:: PRESENCE . to_owned ( ) ,
135+ PresenceTestEvent :: Custom ( json) => json,
129136 }
130137 }
138+ }
131139
132- /// Get the typed JSON representation of this test event.
133- pub fn into_raw_event ( self ) -> Raw < PresenceEvent > {
134- from_json_value ( self . into_json_value ( ) ) . unwrap ( )
140+ impl From < PresenceTestEvent > for Raw < PresenceEvent > {
141+ fn from ( val : PresenceTestEvent ) -> Self {
142+ from_json_value ( val . into ( ) ) . unwrap ( )
135143 }
136144}
137145
@@ -142,18 +150,18 @@ pub enum GlobalAccountDataTestEvent {
142150 Custom ( JsonValue ) ,
143151}
144152
145- impl GlobalAccountDataTestEvent {
146- /// Get the JSON representation of this test event.
147- pub fn into_json_value ( self ) -> JsonValue {
148- match self {
149- Self :: Direct => test_json:: sync_events:: DIRECT . to_owned ( ) ,
150- Self :: PushRules => test_json:: sync_events:: PUSH_RULES . to_owned ( ) ,
151- Self :: Custom ( json) => json,
153+ impl From < GlobalAccountDataTestEvent > for JsonValue {
154+ fn from ( val : GlobalAccountDataTestEvent ) -> Self {
155+ match val {
156+ GlobalAccountDataTestEvent :: Direct => test_json:: sync_events:: DIRECT . to_owned ( ) ,
157+ GlobalAccountDataTestEvent :: PushRules => test_json:: sync_events:: PUSH_RULES . to_owned ( ) ,
158+ GlobalAccountDataTestEvent :: Custom ( json) => json,
152159 }
153160 }
161+ }
154162
155- /// Get the typed JSON representation of this test event.
156- pub fn into_raw_event ( self ) -> Raw < AnyGlobalAccountDataEvent > {
157- from_json_value ( self . into_json_value ( ) ) . unwrap ( )
163+ impl From < GlobalAccountDataTestEvent > for Raw < AnyGlobalAccountDataEvent > {
164+ fn from ( val : GlobalAccountDataTestEvent ) -> Self {
165+ from_json_value ( val . into ( ) ) . unwrap ( )
158166 }
159167}
0 commit comments