Exhausively match EventType in collection deserilization code
This commit is contained in:
parent
3b78391fbc
commit
63e32f2b01
@ -457,7 +457,27 @@ impl<'de> Deserialize<'de> for RoomEvent {
|
|||||||
from_value(value, RoomEvent::CustomRoom)
|
from_value(value, RoomEvent::CustomRoom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => Err(D::Error::custom("invalid event type")),
|
Direct
|
||||||
|
| Dummy
|
||||||
|
| ForwardedRoomKey
|
||||||
|
| FullyRead
|
||||||
|
| IgnoredUserList
|
||||||
|
| KeyVerificationAccept
|
||||||
|
| KeyVerificationCancel
|
||||||
|
| KeyVerificationKey
|
||||||
|
| KeyVerificationMac
|
||||||
|
| KeyVerificationRequest
|
||||||
|
| KeyVerificationStart
|
||||||
|
| Presence
|
||||||
|
| PushRules
|
||||||
|
| Receipt
|
||||||
|
| RoomKey
|
||||||
|
| RoomKeyRequest
|
||||||
|
| Tag
|
||||||
|
| Typing => Err(D::Error::custom("invalid event type")),
|
||||||
|
__Nonexhaustive => {
|
||||||
|
unreachable!("__Nonexhaustive variant should be impossible to obtain.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -491,7 +511,36 @@ impl<'de> Deserialize<'de> for StateEvent {
|
|||||||
RoomTombstone => from_value(value, StateEvent::RoomTombstone),
|
RoomTombstone => from_value(value, StateEvent::RoomTombstone),
|
||||||
RoomTopic => from_value(value, StateEvent::RoomTopic),
|
RoomTopic => from_value(value, StateEvent::RoomTopic),
|
||||||
Custom(_event_type_name) => from_value(value, StateEvent::CustomState),
|
Custom(_event_type_name) => from_value(value, StateEvent::CustomState),
|
||||||
_ => Err(D::Error::custom("invalid event type")),
|
CallAnswer
|
||||||
|
| CallCandidates
|
||||||
|
| CallHangup
|
||||||
|
| CallInvite
|
||||||
|
| Direct
|
||||||
|
| Dummy
|
||||||
|
| ForwardedRoomKey
|
||||||
|
| FullyRead
|
||||||
|
| IgnoredUserList
|
||||||
|
| KeyVerificationAccept
|
||||||
|
| KeyVerificationCancel
|
||||||
|
| KeyVerificationKey
|
||||||
|
| KeyVerificationMac
|
||||||
|
| KeyVerificationRequest
|
||||||
|
| KeyVerificationStart
|
||||||
|
| Presence
|
||||||
|
| PushRules
|
||||||
|
| Receipt
|
||||||
|
| RoomEncrypted
|
||||||
|
| RoomKey
|
||||||
|
| RoomKeyRequest
|
||||||
|
| RoomMessage
|
||||||
|
| RoomMessageFeedback
|
||||||
|
| RoomRedaction
|
||||||
|
| Sticker
|
||||||
|
| Tag
|
||||||
|
| Typing => Err(D::Error::custom("invalid event type")),
|
||||||
|
__Nonexhaustive => {
|
||||||
|
unreachable!("__Nonexhaustive variant should be impossible to obtain.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,34 @@ impl<'de> Deserialize<'de> for Event {
|
|||||||
Tag => from_value(value, Event::Tag),
|
Tag => from_value(value, Event::Tag),
|
||||||
Typing => from_value(value, Event::Typing),
|
Typing => from_value(value, Event::Typing),
|
||||||
Custom(_event_type_name) => from_value(value, Event::Custom),
|
Custom(_event_type_name) => from_value(value, Event::Custom),
|
||||||
_ => Err(D::Error::custom("invalid event type")),
|
CallAnswer
|
||||||
|
| CallCandidates
|
||||||
|
| CallHangup
|
||||||
|
| CallInvite
|
||||||
|
| RoomAliases
|
||||||
|
| RoomAvatar
|
||||||
|
| RoomCanonicalAlias
|
||||||
|
| RoomCreate
|
||||||
|
| RoomEncrypted
|
||||||
|
| RoomEncryption
|
||||||
|
| RoomGuestAccess
|
||||||
|
| RoomHistoryVisibility
|
||||||
|
| RoomJoinRules
|
||||||
|
| RoomMember
|
||||||
|
| RoomMessage
|
||||||
|
| RoomMessageFeedback
|
||||||
|
| RoomName
|
||||||
|
| RoomPinnedEvents
|
||||||
|
| RoomPowerLevels
|
||||||
|
| RoomServerAcl
|
||||||
|
| RoomThirdPartyInvite
|
||||||
|
| RoomTombstone
|
||||||
|
| RoomTopic
|
||||||
|
| RoomRedaction
|
||||||
|
| Sticker => Err(D::Error::custom("invalid event type")),
|
||||||
|
__Nonexhaustive => {
|
||||||
|
unreachable!("__Nonexhaustive variant should be impossible to obtain.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,7 +230,43 @@ impl<'de> Deserialize<'de> for RoomEvent {
|
|||||||
RoomRedaction => from_value(value, RoomEvent::RoomRedaction),
|
RoomRedaction => from_value(value, RoomEvent::RoomRedaction),
|
||||||
Sticker => from_value(value, RoomEvent::Sticker),
|
Sticker => from_value(value, RoomEvent::Sticker),
|
||||||
Custom(_event_type_name) => from_value(value, RoomEvent::CustomRoom),
|
Custom(_event_type_name) => from_value(value, RoomEvent::CustomRoom),
|
||||||
_ => Err(D::Error::custom("invalid event type")),
|
Direct
|
||||||
|
| Dummy
|
||||||
|
| ForwardedRoomKey
|
||||||
|
| FullyRead
|
||||||
|
| IgnoredUserList
|
||||||
|
| KeyVerificationAccept
|
||||||
|
| KeyVerificationCancel
|
||||||
|
| KeyVerificationKey
|
||||||
|
| KeyVerificationMac
|
||||||
|
| KeyVerificationRequest
|
||||||
|
| KeyVerificationStart
|
||||||
|
| Presence
|
||||||
|
| PushRules
|
||||||
|
| Receipt
|
||||||
|
| RoomAvatar
|
||||||
|
| RoomAliases
|
||||||
|
| RoomCanonicalAlias
|
||||||
|
| RoomCreate
|
||||||
|
| RoomEncryption
|
||||||
|
| RoomGuestAccess
|
||||||
|
| RoomHistoryVisibility
|
||||||
|
| RoomJoinRules
|
||||||
|
| RoomKey
|
||||||
|
| RoomKeyRequest
|
||||||
|
| RoomMember
|
||||||
|
| RoomName
|
||||||
|
| RoomPinnedEvents
|
||||||
|
| RoomPowerLevels
|
||||||
|
| RoomServerAcl
|
||||||
|
| RoomThirdPartyInvite
|
||||||
|
| RoomTombstone
|
||||||
|
| RoomTopic
|
||||||
|
| Tag
|
||||||
|
| Typing => Err(D::Error::custom("invalid event type")),
|
||||||
|
__Nonexhaustive => {
|
||||||
|
unreachable!("__Nonexhaustive variant should be impossible to obtain.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user