Add event_enums.rs
only contains AnyStateEvent for now, more will be added
This commit is contained in:
		
							parent
							
								
									d3b17e2b5b
								
							
						
					
					
						commit
						8c271fb835
					
				
							
								
								
									
										58
									
								
								src/event_enums.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								src/event_enums.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,58 @@ | |||||||
|  | use serde::{Deserialize, Serialize}; | ||||||
|  | 
 | ||||||
|  | use crate::{ | ||||||
|  |     room::{ | ||||||
|  |         aliases::AliasesEventContent, avatar::AvatarEventContent, | ||||||
|  |         canonical_alias::CanonicalAliasEventContent, create::CreateEventContent, | ||||||
|  |         encryption::EncryptionEventContent, guest_access::GuestAccessEventContent, | ||||||
|  |         history_visibility::HistoryVisibilityEventContent, join_rules::JoinRulesEventContent, | ||||||
|  |         member::MemberEventContent, name::NameEventContent, | ||||||
|  |         pinned_events::PinnedEventsEventContent, power_levels::PowerLevelsEventContent, | ||||||
|  |         server_acl::ServerAclEventContent, third_party_invite::ThirdPartyInviteEventContent, | ||||||
|  |         tombstone::TombstoneEventContent, topic::TopicEventContent, | ||||||
|  |     }, | ||||||
|  |     StateEvent, | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | // TODO: Optimize `Deserialize` implementations.
 | ||||||
|  | // It should be possible to first deserialize into CatchAllEvent<AnyWhateverEventContent> and
 | ||||||
|  | // transform that, which should have much more consistent performance than trying all variants
 | ||||||
|  | // in order.
 | ||||||
|  | 
 | ||||||
|  | /// Any state event.
 | ||||||
|  | #[derive(Clone, Debug, Deserialize, Serialize)] | ||||||
|  | #[serde(untagged)] | ||||||
|  | pub enum AnyStateEvent { | ||||||
|  |     /// An `m.room.aliases` event.
 | ||||||
|  |     RoomAliases(StateEvent<AliasesEventContent>), | ||||||
|  |     /// An `m.room.avatar` event.
 | ||||||
|  |     RoomAvatar(StateEvent<AvatarEventContent>), | ||||||
|  |     /// An `m.room.canonical_alias` event.
 | ||||||
|  |     RoomCanonicalAlias(StateEvent<CanonicalAliasEventContent>), | ||||||
|  |     /// An `m.room.create` event.
 | ||||||
|  |     RoomCreate(StateEvent<CreateEventContent>), | ||||||
|  |     /// An `m.room.encryption` event.
 | ||||||
|  |     RoomEncryption(StateEvent<EncryptionEventContent>), | ||||||
|  |     /// An `m.room.guest_access` event.
 | ||||||
|  |     RoomGuestAccess(StateEvent<GuestAccessEventContent>), | ||||||
|  |     /// An `m.room.history_visibility` event.
 | ||||||
|  |     RoomHistoryVisibility(StateEvent<HistoryVisibilityEventContent>), | ||||||
|  |     /// An `m.room.join_rules` event.
 | ||||||
|  |     RoomJoinRules(StateEvent<JoinRulesEventContent>), | ||||||
|  |     /// An `m.room.member` event.
 | ||||||
|  |     RoomMember(StateEvent<MemberEventContent>), | ||||||
|  |     /// An `m.room.name` event.
 | ||||||
|  |     RoomName(StateEvent<NameEventContent>), | ||||||
|  |     /// An `m.room.pinned_events` event.
 | ||||||
|  |     RoomPinnedEvents(StateEvent<PinnedEventsEventContent>), | ||||||
|  |     /// An `m.room.power_levels` event.
 | ||||||
|  |     RoomPowerLevels(StateEvent<PowerLevelsEventContent>), | ||||||
|  |     /// An `m.room.server_acl` event.
 | ||||||
|  |     RoomServerAcl(StateEvent<ServerAclEventContent>), | ||||||
|  |     /// An `m.room.third_party_invite` event.
 | ||||||
|  |     RoomThirdPartyInvite(StateEvent<ThirdPartyInviteEventContent>), | ||||||
|  |     /// An `m.room.tombstone` event.
 | ||||||
|  |     RoomTombstone(StateEvent<TombstoneEventContent>), | ||||||
|  |     /// An `m.room.topic` event.
 | ||||||
|  |     RoomTopic(StateEvent<TopicEventContent>), | ||||||
|  | } | ||||||
| @ -132,6 +132,7 @@ pub use ruma_serde::empty::Empty; | |||||||
| mod algorithm; | mod algorithm; | ||||||
| mod content_enums; | mod content_enums; | ||||||
| mod error; | mod error; | ||||||
|  | mod event_enums; | ||||||
| mod event_kinds; | mod event_kinds; | ||||||
| mod event_type; | mod event_type; | ||||||
| mod from_raw; | mod from_raw; | ||||||
| @ -167,6 +168,7 @@ pub use self::{ | |||||||
|     algorithm::Algorithm, |     algorithm::Algorithm, | ||||||
|     content_enums::{AnyMessageEventContent, AnyStateEventContent}, |     content_enums::{AnyMessageEventContent, AnyStateEventContent}, | ||||||
|     error::{FromStrError, InvalidEvent, InvalidInput}, |     error::{FromStrError, InvalidEvent, InvalidInput}, | ||||||
|  |     event_enums::AnyStateEvent, | ||||||
|     event_kinds::{MessageEvent, StateEvent}, |     event_kinds::{MessageEvent, StateEvent}, | ||||||
|     event_type::EventType, |     event_type::EventType, | ||||||
|     from_raw::{FromRaw, TryFromRaw}, |     from_raw::{FromRaw, TryFromRaw}, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user