Temporarily add back Serialize implementations for non-DAG events
… since they are being used by Conduit.
This commit is contained in:
		
							parent
							
								
									e6c995ef1a
								
							
						
					
					
						commit
						67d0f3cc04
					
				| @ -23,6 +23,18 @@ pub struct GlobalAccountDataEvent<C: GlobalAccountDataEventContent> { | |||||||
|     pub content: C, |     pub content: C, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | impl<C: GlobalAccountDataEventContent> Serialize for GlobalAccountDataEvent<C> { | ||||||
|  |     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||||||
|  |     where | ||||||
|  |         S: serde::Serializer, | ||||||
|  |     { | ||||||
|  |         let mut state = serializer.serialize_struct("GlobalAccountDataEvent", 2)?; | ||||||
|  |         state.serialize_field("type", &self.content.event_type())?; | ||||||
|  |         state.serialize_field("content", &self.content)?; | ||||||
|  |         state.end() | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /// A room account data event.
 | /// A room account data event.
 | ||||||
| #[derive(Clone, Debug, Event)] | #[derive(Clone, Debug, Event)] | ||||||
| pub struct RoomAccountDataEvent<C: RoomAccountDataEventContent> { | pub struct RoomAccountDataEvent<C: RoomAccountDataEventContent> { | ||||||
| @ -30,6 +42,18 @@ pub struct RoomAccountDataEvent<C: RoomAccountDataEventContent> { | |||||||
|     pub content: C, |     pub content: C, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | impl<C: RoomAccountDataEventContent> Serialize for RoomAccountDataEvent<C> { | ||||||
|  |     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||||||
|  |     where | ||||||
|  |         S: serde::Serializer, | ||||||
|  |     { | ||||||
|  |         let mut state = serializer.serialize_struct("RoomAccountDataEvent", 2)?; | ||||||
|  |         state.serialize_field("type", &self.content.event_type())?; | ||||||
|  |         state.serialize_field("content", &self.content)?; | ||||||
|  |         state.end() | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /// An ephemeral room event.
 | /// An ephemeral room event.
 | ||||||
| #[derive(Clone, Debug, Event)] | #[derive(Clone, Debug, Event)] | ||||||
| pub struct EphemeralRoomEvent<C: EphemeralRoomEventContent> { | pub struct EphemeralRoomEvent<C: EphemeralRoomEventContent> { | ||||||
| @ -40,6 +64,19 @@ pub struct EphemeralRoomEvent<C: EphemeralRoomEventContent> { | |||||||
|     pub room_id: OwnedRoomId, |     pub room_id: OwnedRoomId, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | impl<C: EphemeralRoomEventContent> Serialize for EphemeralRoomEvent<C> { | ||||||
|  |     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||||||
|  |     where | ||||||
|  |         S: serde::Serializer, | ||||||
|  |     { | ||||||
|  |         let mut state = serializer.serialize_struct("EphemeralRoomEvent", 2)?; | ||||||
|  |         state.serialize_field("type", &self.content.event_type())?; | ||||||
|  |         state.serialize_field("content", &self.content)?; | ||||||
|  |         state.serialize_field("room_id", &self.room_id)?; | ||||||
|  |         state.end() | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /// An ephemeral room event without a `room_id`.
 | /// An ephemeral room event without a `room_id`.
 | ||||||
| #[derive(Clone, Debug, Event)] | #[derive(Clone, Debug, Event)] | ||||||
| pub struct SyncEphemeralRoomEvent<C: EphemeralRoomEventContent> { | pub struct SyncEphemeralRoomEvent<C: EphemeralRoomEventContent> { | ||||||
| @ -47,6 +84,18 @@ pub struct SyncEphemeralRoomEvent<C: EphemeralRoomEventContent> { | |||||||
|     pub content: C, |     pub content: C, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | impl<C: EphemeralRoomEventContent> Serialize for SyncEphemeralRoomEvent<C> { | ||||||
|  |     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||||||
|  |     where | ||||||
|  |         S: serde::Serializer, | ||||||
|  |     { | ||||||
|  |         let mut state = serializer.serialize_struct("SyncEphemeralRoomEvent", 2)?; | ||||||
|  |         state.serialize_field("type", &self.content.event_type())?; | ||||||
|  |         state.serialize_field("content", &self.content)?; | ||||||
|  |         state.end() | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /// An unredacted message-like event.
 | /// An unredacted message-like event.
 | ||||||
| ///
 | ///
 | ||||||
| /// `OriginalMessageLikeEvent` implements the comparison traits using only the `event_id` field, a
 | /// `OriginalMessageLikeEvent` implements the comparison traits using only the `event_id` field, a
 | ||||||
|  | |||||||
| @ -4,9 +4,9 @@ | |||||||
| 
 | 
 | ||||||
| use js_int::UInt; | use js_int::UInt; | ||||||
| use ruma_macros::{Event, EventContent}; | use ruma_macros::{Event, EventContent}; | ||||||
| use serde::{Deserialize, Serialize}; | use serde::{ser::SerializeStruct, Deserialize, Serialize}; | ||||||
| 
 | 
 | ||||||
| use super::{EventKind, StaticEventContent}; | use super::{EventContent, EventKind, StaticEventContent}; | ||||||
| use crate::{presence::PresenceState, OwnedMxcUri, OwnedUserId}; | use crate::{presence::PresenceState, OwnedMxcUri, OwnedUserId}; | ||||||
| 
 | 
 | ||||||
| /// Presence event.
 | /// Presence event.
 | ||||||
| @ -20,6 +20,19 @@ pub struct PresenceEvent { | |||||||
|     pub sender: OwnedUserId, |     pub sender: OwnedUserId, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | impl Serialize for PresenceEvent { | ||||||
|  |     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||||||
|  |     where | ||||||
|  |         S: serde::Serializer, | ||||||
|  |     { | ||||||
|  |         let mut state = serializer.serialize_struct("PresenceEvent", 3)?; | ||||||
|  |         state.serialize_field("type", &self.content.event_type())?; | ||||||
|  |         state.serialize_field("content", &self.content)?; | ||||||
|  |         state.serialize_field("sender", &self.sender)?; | ||||||
|  |         state.end() | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /// Informs the room of members presence.
 | /// Informs the room of members presence.
 | ||||||
| ///
 | ///
 | ||||||
| /// This is the only type a `PresenceEvent` can contain as its `content` field.
 | /// This is the only type a `PresenceEvent` can contain as its `content` field.
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user