From f4b7204f31d43f44a1644234669f3cd821624faf Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Sat, 15 Jun 2019 00:03:32 -0700 Subject: [PATCH] Derive PartialEq where possible. --- src/call.rs | 2 +- src/call/answer.rs | 2 +- src/call/candidates.rs | 4 ++-- src/call/hangup.rs | 2 +- src/call/invite.rs | 2 +- src/key/verification/key.rs | 2 +- src/lib.rs | 2 +- src/receipt.rs | 4 ++-- src/room/aliases.rs | 2 +- src/room/avatar.rs | 2 +- src/room/canonical_alias.rs | 2 +- src/room/guest_access.rs | 2 +- src/room/history_visibility.rs | 2 +- src/room/join_rules.rs | 2 +- src/room/name.rs | 2 +- src/room/pinned_events.rs | 2 +- src/room/power_levels.rs | 4 ++-- src/room/redaction.rs | 2 +- src/room/third_party_invite.rs | 4 ++-- src/room/topic.rs | 2 +- src/stripped.rs | 2 +- src/tag.rs | 4 ++-- src/typing.rs | 2 +- 23 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/call.rs b/src/call.rs index 4f34ce66..7a53946c 100644 --- a/src/call.rs +++ b/src/call.rs @@ -10,7 +10,7 @@ pub mod hangup; pub mod invite; /// A VoIP session description. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct SessionDescription { /// The type of session description. #[serde(rename = "type")] diff --git a/src/call/answer.rs b/src/call/answer.rs index 693842c6..3bef8ad6 100644 --- a/src/call/answer.rs +++ b/src/call/answer.rs @@ -10,7 +10,7 @@ room_event! { } /// The payload of an `AnswerEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct AnswerEventContent { /// The VoIP session description object. The session description type must be *answer*. pub answer: SessionDescription, diff --git a/src/call/candidates.rs b/src/call/candidates.rs index 0dc75ac9..b6c47abe 100644 --- a/src/call/candidates.rs +++ b/src/call/candidates.rs @@ -10,7 +10,7 @@ room_event! { } /// The payload of a `CandidatesEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct CandidatesEventContent { /// The ID of the call this event relates to. pub call_id: String, @@ -23,7 +23,7 @@ pub struct CandidatesEventContent { } /// An ICE (Interactive Connectivity Establishment) candidate. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct Candidate { /// The SDP "a" line of the candidate. pub candidate: String, diff --git a/src/call/hangup.rs b/src/call/hangup.rs index 74fccc97..e8a20a43 100644 --- a/src/call/hangup.rs +++ b/src/call/hangup.rs @@ -9,7 +9,7 @@ room_event! { } /// The payload of a `HangupEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct HangupEventContent { /// The ID of the call this event relates to. pub call_id: String, diff --git a/src/call/invite.rs b/src/call/invite.rs index 0929a438..de48ccd5 100644 --- a/src/call/invite.rs +++ b/src/call/invite.rs @@ -10,7 +10,7 @@ room_event! { } /// The payload of an `InviteEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InviteEventContent { /// A unique identifer for the call. pub call_id: String, diff --git a/src/key/verification/key.rs b/src/key/verification/key.rs index 07cb1067..1947d687 100644 --- a/src/key/verification/key.rs +++ b/src/key/verification/key.rs @@ -10,7 +10,7 @@ event! { } /// The payload of an *m.key.verification.key* event. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct KeyEventContent { /// An opaque identifier for the verification process. /// diff --git a/src/lib.rs b/src/lib.rs index 3ca49419..cf25b557 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -134,7 +134,7 @@ pub mod tag; pub mod typing; /// An error when attempting to convert a string to an enum that only accepts certain values. -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Eq, Debug, Hash, PartialEq)] pub struct ParseError; /// The type of an event. diff --git a/src/receipt.rs b/src/receipt.rs index 28faf7d5..7e2c290e 100644 --- a/src/receipt.rs +++ b/src/receipt.rs @@ -20,7 +20,7 @@ event! { pub type ReceiptEventContent = HashMap; /// A collection of receipts. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct Receipts { /// A collection of users who have sent *m.read* receipts for this event. #[serde(rename = "m.read")] @@ -34,7 +34,7 @@ pub struct Receipts { pub type UserReceipts = HashMap; /// An acknowledgement of an event. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct Receipt { /// The timestamp (milliseconds since the Unix epoch) when the receipt was sent. pub ts: Option, diff --git a/src/room/aliases.rs b/src/room/aliases.rs index 0a8edddf..505597d9 100644 --- a/src/room/aliases.rs +++ b/src/room/aliases.rs @@ -9,7 +9,7 @@ state_event! { } /// The payload of an `AliasesEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct AliasesEventContent { /// A list of room aliases. pub aliases: Vec, diff --git a/src/room/avatar.rs b/src/room/avatar.rs index fbd6a736..4d5c9f28 100644 --- a/src/room/avatar.rs +++ b/src/room/avatar.rs @@ -12,7 +12,7 @@ state_event! { } /// The payload of an `AvatarEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct AvatarEventContent { /// Information about the avatar image. #[serde(skip_serializing_if = "Option::is_none")] diff --git a/src/room/canonical_alias.rs b/src/room/canonical_alias.rs index c8b4c6bc..c1225a82 100644 --- a/src/room/canonical_alias.rs +++ b/src/room/canonical_alias.rs @@ -10,7 +10,7 @@ state_event! { } /// The payload of a `CanonicalAliasEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct CanonicalAliasEventContent { /// The canonical alias. /// Rooms with `alias: None` should be treated the same as a room with no canonical alias. diff --git a/src/room/guest_access.rs b/src/room/guest_access.rs index 65485171..a19a85c2 100644 --- a/src/room/guest_access.rs +++ b/src/room/guest_access.rs @@ -11,7 +11,7 @@ state_event! { } /// The payload of a `GuestAccessEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct GuestAccessEventContent { /// A policy for guest user access to a room. pub guest_access: GuestAccess, diff --git a/src/room/history_visibility.rs b/src/room/history_visibility.rs index ba3dd0be..d5a93b45 100644 --- a/src/room/history_visibility.rs +++ b/src/room/history_visibility.rs @@ -9,7 +9,7 @@ state_event! { } /// The payload of a `HistoryVisibilityEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct HistoryVisibilityEventContent { /// Who can see the room history. pub history_visibility: HistoryVisibility, diff --git a/src/room/join_rules.rs b/src/room/join_rules.rs index c34f992f..85aec720 100644 --- a/src/room/join_rules.rs +++ b/src/room/join_rules.rs @@ -8,7 +8,7 @@ state_event! { } /// The payload of a `JoinRulesEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct JoinRulesEventContent { /// The type of rules used for users wishing to join this room. pub join_rule: JoinRule, diff --git a/src/room/name.rs b/src/room/name.rs index 894bfee4..4563e908 100644 --- a/src/room/name.rs +++ b/src/room/name.rs @@ -9,7 +9,7 @@ state_event! { } /// The payload of a `NameEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct NameEventContent { /// The name of the room. This MUST NOT exceed 255 bytes. // The spec says “A room with an m.room.name event with an absent, null, or empty name field diff --git a/src/room/pinned_events.rs b/src/room/pinned_events.rs index 52438658..77104aae 100644 --- a/src/room/pinned_events.rs +++ b/src/room/pinned_events.rs @@ -9,7 +9,7 @@ state_event! { } /// The payload of a `NameEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct PinnedEventsContent { /// An ordered list of event IDs to pin. pub pinned: Vec, diff --git a/src/room/power_levels.rs b/src/room/power_levels.rs index 927ea4d0..a61d4d7b 100644 --- a/src/room/power_levels.rs +++ b/src/room/power_levels.rs @@ -13,7 +13,7 @@ state_event! { } /// The payload of a `PowerLevelsEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct PowerLevelsEventContent { /// The level required to ban a user. #[serde(default = "default_power_level")] @@ -60,7 +60,7 @@ pub struct PowerLevelsEventContent { } /// The power level requirements for specific notification types. -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] pub struct NotificationPowerLevels { /// The level required to trigger an `@room` notification. #[serde(default = "default_power_level")] diff --git a/src/room/redaction.rs b/src/room/redaction.rs index cb4da09d..acd78bd4 100644 --- a/src/room/redaction.rs +++ b/src/room/redaction.rs @@ -12,7 +12,7 @@ room_event! { } /// The payload of a `RedactionEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct RedactionEventContent { /// The reason for the redaction, if any. #[serde(skip_serializing_if = "Option::is_none")] diff --git a/src/room/third_party_invite.rs b/src/room/third_party_invite.rs index 790bb141..5f0bd30b 100644 --- a/src/room/third_party_invite.rs +++ b/src/room/third_party_invite.rs @@ -12,7 +12,7 @@ state_event! { } /// The payload of a `ThirdPartyInviteEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct ThirdPartyInviteEventContent { /// A user-readable string which represents the user who has been invited. pub display_name: String, @@ -29,7 +29,7 @@ pub struct ThirdPartyInviteEventContent { } /// A public key for signing a third party invite token. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct PublicKey { /// An optional URL which can be fetched to validate whether the key has been revoked. /// diff --git a/src/room/topic.rs b/src/room/topic.rs index 45495a65..124f15e6 100644 --- a/src/room/topic.rs +++ b/src/room/topic.rs @@ -8,7 +8,7 @@ state_event! { } /// The payload of a `TopicEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct TopicEventContent { /// The topic text. pub topic: String, diff --git a/src/stripped.rs b/src/stripped.rs index 23c121fc..419b0f78 100644 --- a/src/stripped.rs +++ b/src/stripped.rs @@ -63,7 +63,7 @@ pub enum StrippedState { } /// A "stripped-down" version of a core state event. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct StrippedStateContent { /// Data specific to the event type. pub content: C, diff --git a/src/tag.rs b/src/tag.rs index 404cfbf0..050743b0 100644 --- a/src/tag.rs +++ b/src/tag.rs @@ -10,14 +10,14 @@ event! { } /// The payload of a `TagEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct TagEventContent { /// A map of tag names to tag info. pub tags: HashMap, } /// Information about a tag. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct TagInfo { /// Value to use for lexicographically ordering rooms with this tag. #[serde(skip_serializing_if = "Option::is_none")] diff --git a/src/typing.rs b/src/typing.rs index dc907395..eb7f2cfc 100644 --- a/src/typing.rs +++ b/src/typing.rs @@ -12,7 +12,7 @@ event! { } /// The payload of a `TypingEvent`. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct TypingEventContent { /// The list of user IDs typing in this room, if any. pub user_ids: Vec,