diff --git a/ruma-events-macros/src/gen.rs b/ruma-events-macros/src/gen.rs index a0ee1d8d..db649ce0 100644 --- a/ruma-events-macros/src/gen.rs +++ b/ruma-events-macros/src/gen.rs @@ -95,7 +95,7 @@ impl ToTokens for RumaEvent { Content::Struct(fields) => { quote! { #[doc = #content_docstring] - #[derive(Clone, Debug, PartialEq, serde::Serialize)] + #[derive(Clone, Debug, serde::Serialize)] pub struct #content_name { #(#fields),* } @@ -116,7 +116,7 @@ impl ToTokens for RumaEvent { Content::Struct(fields) => { quote! { #[doc = #content_docstring] - #[derive(Clone, Debug, PartialEq, serde::Deserialize)] + #[derive(Clone, Debug, serde::Deserialize)] pub struct #content_name { #(#fields),* } @@ -216,7 +216,7 @@ impl ToTokens for RumaEvent { let event_type_name = self.event_type.value(); let output = quote!( #(#attrs)* - #[derive(Clone, PartialEq, Debug, serde::Serialize, ruma_events_macros::FromRaw)] + #[derive(Clone, Debug, serde::Serialize, ruma_events_macros::FromRaw)] #[serde(rename = #event_type_name, tag = "type")] pub struct #name { #(#event_fields),* @@ -250,7 +250,7 @@ impl ToTokens for RumaEvent { use super::*; #(#attrs)* - #[derive(Clone, Debug, PartialEq, serde::Deserialize)] + #[derive(Clone, Debug, serde::Deserialize)] pub struct #name { #(#event_fields),* } diff --git a/src/algorithm.rs b/src/algorithm.rs index ba3a5284..803f3f61 100644 --- a/src/algorithm.rs +++ b/src/algorithm.rs @@ -1,14 +1,10 @@ -use std::{ - borrow::Cow, - fmt::{Display, Formatter, Result as FmtResult}, -}; +use std::fmt::{Display, Formatter, Result as FmtResult}; use serde::{Deserialize, Serialize}; /// An encryption algorithm to be used to encrypt messages sent to a room. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] -// Cow because deserialization sometimes needs to copy to unescape things -#[serde(from = "Cow<'_, str>", into = "String")] +#[serde(from = "String", into = "String")] pub enum Algorithm { /// Olm version 1 using Curve25519, AES-256, and SHA-256. OlmV1Curve25519AesSha2, @@ -40,22 +36,19 @@ impl Display for Algorithm { } } -impl From> for Algorithm { - fn from(s: Cow<'_, str>) -> Algorithm { - match &s as &str { +impl From for Algorithm +where + T: Into + AsRef, +{ + fn from(s: T) -> Algorithm { + match s.as_ref() { "m.olm.v1.curve25519-aes-sha2" => Algorithm::OlmV1Curve25519AesSha2, "m.megolm.v1.aes-sha2" => Algorithm::MegolmV1AesSha2, - _ => Algorithm::Custom(s.into_owned()), + _ => Algorithm::Custom(s.into()), } } } -impl From<&str> for Algorithm { - fn from(s: &str) -> Algorithm { - Algorithm::from(Cow::Borrowed(s)) - } -} - impl From for String { fn from(algorithm: Algorithm) -> String { algorithm.to_string() diff --git a/src/call/candidates.rs b/src/call/candidates.rs index cb275658..e5319956 100644 --- a/src/call/candidates.rs +++ b/src/call/candidates.rs @@ -25,7 +25,7 @@ ruma_event! { } /// An ICE (Interactive Connectivity Establishment) candidate. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Candidate { /// The SDP "a" line of the candidate. diff --git a/src/custom.rs b/src/custom.rs index 0e95c171..17c88797 100644 --- a/src/custom.rs +++ b/src/custom.rs @@ -10,7 +10,7 @@ use serde::Serialize; use serde_json::Value as JsonValue; /// A custom event not covered by the Matrix specification. -#[derive(Clone, Debug, FromRaw, PartialEq, Serialize)] +#[derive(Clone, Debug, FromRaw, Serialize)] pub struct CustomEvent { /// The event's content. pub content: CustomEventContent, @@ -38,7 +38,7 @@ impl Event for CustomEvent { } /// A custom room event not covered by the Matrix specification. -#[derive(Clone, Debug, FromRaw, PartialEq, Serialize)] +#[derive(Clone, Debug, FromRaw, Serialize)] pub struct CustomRoomEvent { /// The event's content. pub content: CustomRoomEventContent, @@ -108,7 +108,7 @@ impl RoomEvent for CustomRoomEvent { } /// A custom state event not covered by the Matrix specification. -#[derive(Clone, Debug, FromRaw, PartialEq, Serialize)] +#[derive(Clone, Debug, FromRaw, Serialize)] pub struct CustomStateEvent { /// The event's content. pub content: CustomStateEventContent, @@ -204,7 +204,7 @@ pub(crate) mod raw { }; /// A custom event not covered by the Matrix specification. - #[derive(Clone, Debug, PartialEq, Deserialize)] + #[derive(Clone, Debug, Deserialize)] pub struct CustomEvent { /// The event's content. pub content: CustomEventContent, @@ -214,7 +214,7 @@ pub(crate) mod raw { } /// A custom room event not covered by the Matrix specification. - #[derive(Clone, Debug, PartialEq, Deserialize)] + #[derive(Clone, Debug, Deserialize)] pub struct CustomRoomEvent { /// The event's content. pub content: CustomRoomEventContent, @@ -236,7 +236,7 @@ pub(crate) mod raw { } /// A custom state event not covered by the Matrix specification. - #[derive(Clone, Debug, PartialEq, Deserialize)] + #[derive(Clone, Debug, Deserialize)] pub struct CustomStateEvent { /// The event's content. pub content: CustomStateEventContent, diff --git a/src/event_type.rs b/src/event_type.rs index 445c0973..95113922 100644 --- a/src/event_type.rs +++ b/src/event_type.rs @@ -1,14 +1,10 @@ -use std::{ - borrow::Cow, - fmt::{Display, Formatter, Result as FmtResult}, -}; +use std::fmt::{Display, Formatter, Result as FmtResult}; use serde::{Deserialize, Serialize}; /// The type of an event. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] -// Cow because deserialization sometimes needs to copy to unescape things -#[serde(from = "Cow<'_, str>", into = "String")] +#[serde(from = "String", into = "String")] pub enum EventType { /// m.call.answer CallAnswer, @@ -204,9 +200,12 @@ impl Display for EventType { } } -impl From> for EventType { - fn from(s: Cow<'_, str>) -> EventType { - match &s as &str { +impl From for EventType +where + T: Into + AsRef, +{ + fn from(s: T) -> EventType { + match s.as_ref() { "m.call.answer" => EventType::CallAnswer, "m.call.candidates" => EventType::CallCandidates, "m.call.hangup" => EventType::CallHangup, @@ -250,17 +249,11 @@ impl From> for EventType { "m.sticker" => EventType::Sticker, "m.tag" => EventType::Tag, "m.typing" => EventType::Typing, - _ => EventType::Custom(s.into_owned()), + _ => EventType::Custom(s.into()), } } } -impl<'a> From<&str> for EventType { - fn from(s: &str) -> EventType { - EventType::from(Cow::Borrowed(s)) - } -} - impl From for String { fn from(event_type: EventType) -> String { event_type.to_string() diff --git a/src/ignored_user_list.rs b/src/ignored_user_list.rs index cdf189df..726993c5 100644 --- a/src/ignored_user_list.rs +++ b/src/ignored_user_list.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; use crate::{EventType, FromRaw}; /// A list of users to ignore. -#[derive(Clone, Debug, PartialEq, Serialize)] +#[derive(Clone, Debug, Serialize)] #[serde(rename = "m.ignored_user_list", tag = "type")] pub struct IgnoredUserListEvent { /// The event's content. @@ -24,7 +24,7 @@ impl FromRaw for IgnoredUserListEvent { } /// The payload for `IgnoredUserListEvent`. -#[derive(Clone, Debug, PartialEq, Serialize)] +#[derive(Clone, Debug, Serialize)] pub struct IgnoredUserListEventContent { /// A list of users to ignore. #[serde(with = "ruma_serde::vec_as_map_of_empty")] @@ -110,8 +110,8 @@ mod tests { assert_matches!( from_json_value::>(json) - .unwrap() - .deserialize() + .unwrap() + .deserialize() .unwrap(), IgnoredUserListEvent { content: IgnoredUserListEventContent { ignored_users, }, diff --git a/src/json.rs b/src/json.rs index 386df371..e9a7f729 100644 --- a/src/json.rs +++ b/src/json.rs @@ -95,12 +95,6 @@ impl Debug for EventJson { } } -impl PartialEq for EventJson { - fn eq(&self, other: &Self) -> bool { - self.json.get() == other.json.get() - } -} - impl<'de, T> Deserialize<'de> for EventJson { fn deserialize(deserializer: D) -> Result where diff --git a/src/key/verification/cancel.rs b/src/key/verification/cancel.rs index 6012395e..d4430ade 100644 --- a/src/key/verification/cancel.rs +++ b/src/key/verification/cancel.rs @@ -1,9 +1,6 @@ //! Types for the *m.key.verification.cancel* event. -use std::{ - borrow::Cow, - fmt::{Display, Formatter, Result as FmtResult}, -}; +use std::fmt::{Display, Formatter, Result as FmtResult}; use ruma_events_macros::ruma_event; use serde::{Deserialize, Serialize}; @@ -34,8 +31,7 @@ ruma_event! { /// /// Custom error codes should use the Java package naming convention. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] -// Cow because deserialization sometimes needs to copy to unescape things -#[serde(from = "Cow<'_, str>", into = "String")] +#[serde(from = "String", into = "String")] pub enum CancelCode { /// The user cancelled the verification. User, @@ -103,9 +99,12 @@ impl Display for CancelCode { } } -impl From> for CancelCode { - fn from(s: Cow<'_, str>) -> CancelCode { - match &s as &str { +impl From for CancelCode +where + T: Into + AsRef, +{ + fn from(s: T) -> CancelCode { + match s.as_ref() { "m.user" => CancelCode::User, "m.timeout" => CancelCode::Timeout, "m.unknown_transaction" => CancelCode::UnknownTransaction, @@ -115,17 +114,11 @@ impl From> for CancelCode { "m.user_mismatch" => CancelCode::UserMismatch, "m.invalid_message" => CancelCode::InvalidMessage, "m.accepted" => CancelCode::Accepted, - _ => CancelCode::Custom(s.into_owned()), + _ => CancelCode::Custom(s.into()), } } } -impl From<&str> for CancelCode { - fn from(s: &str) -> CancelCode { - CancelCode::from(Cow::Borrowed(s)) - } -} - impl From for String { fn from(cancel_code: CancelCode) -> String { cancel_code.to_string() diff --git a/src/key/verification/start.rs b/src/key/verification/start.rs index b94511b3..9df6739f 100644 --- a/src/key/verification/start.rs +++ b/src/key/verification/start.rs @@ -12,7 +12,7 @@ use crate::{EventType, InvalidInput, TryFromRaw}; /// Begins an SAS key verification process. /// /// Typically sent as a to-device event. -#[derive(Clone, Debug, PartialEq, Serialize)] +#[derive(Clone, Debug, Serialize)] #[serde(tag = "type", rename = "m.key.verification.start")] pub struct StartEvent { /// The event's content. @@ -20,7 +20,7 @@ pub struct StartEvent { } /// The payload of an *m.key.verification.start* event. -#[derive(Clone, Debug, PartialEq, Serialize)] +#[derive(Clone, Debug, Serialize)] #[serde(untagged)] pub enum StartEventContent { /// The *m.sas.v1* verification method. @@ -103,14 +103,14 @@ pub(crate) mod raw { /// Begins an SAS key verification process. /// /// Typically sent as a to-device event. - #[derive(Clone, Debug, PartialEq, Deserialize)] + #[derive(Clone, Debug, Deserialize)] pub struct StartEvent { /// The event's content. pub content: StartEventContent, } /// The payload of an *m.key.verification.start* event. - #[derive(Clone, Debug, PartialEq)] + #[derive(Clone, Debug)] pub enum StartEventContent { /// The *m.sas.v1* verification method. MSasV1(MSasV1Content), @@ -158,7 +158,7 @@ pub(crate) mod raw { } /// The payload of an *m.key.verification.start* event using the *m.sas.v1* method. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "method", rename = "m.sas.v1")] pub struct MSasV1Content { /// The device ID which is initiating the process. @@ -193,7 +193,7 @@ pub struct MSasV1Content { } /// Options for creating an `MSasV1Content` with `MSasV1Content::new`. -#[derive(Clone, Debug, PartialEq, Deserialize)] +#[derive(Clone, Debug, Deserialize)] pub struct MSasV1ContentOptions { /// The device ID which is initiating the process. pub from_device: DeviceId, diff --git a/src/lib.rs b/src/lib.rs index a630194d..0175e64f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -224,7 +224,7 @@ pub trait StateEvent: RoomEvent { /// Extra information about an event that is not incorporated into the event's /// hash. -#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Default, Deserialize, Serialize)] pub struct UnsignedData { /// The time in milliseconds that has elapsed since the event was sent. This /// field is generated by the local homeserver, and may be incorrect if the @@ -232,9 +232,11 @@ pub struct UnsignedData { /// cause the age to either be negative or greater than it actually is. #[serde(skip_serializing_if = "Option::is_none")] pub age: Option, + /// The event that redacted this event, if any. #[serde(skip_serializing_if = "Option::is_none")] pub redacted_because: Option>, + /// The client-supplied transaction ID, if the client being given the event /// is the same one which sent it. #[serde(skip_serializing_if = "Option::is_none")] diff --git a/src/push_rules.rs b/src/push_rules.rs index af35a716..65b8fb17 100644 --- a/src/push_rules.rs +++ b/src/push_rules.rs @@ -31,7 +31,7 @@ ruma_event! { /// /// For example, some rules may only be applied for messages from a particular sender, a particular /// room, or by default. The push ruleset contains the entire set of scopes and rules. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct Ruleset { /// These rules configure behaviour for (unencrypted) messages that match certain patterns. pub content: Vec, @@ -56,7 +56,7 @@ pub struct Ruleset { /// /// These rules are stored on the user's homeserver. They are manually configured by the user, who /// can create and view them via the Client/Server API. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct PushRule { /// Actions to determine if and how a notification is delivered for events matching this rule. pub actions: Vec, @@ -74,7 +74,7 @@ pub struct PushRule { /// Like `PushRule`, but with an additional `conditions` field. /// /// Only applicable to underride and override rules. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct ConditionalPushRule { /// Actions to determine if and how a notification is delivered for events matching this rule. pub actions: Vec, @@ -97,7 +97,7 @@ pub struct ConditionalPushRule { /// Like `PushRule`, but with an additional `pattern` field. /// /// Only applicable to content rules. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct PatternedPushRule { /// Actions to determine if and how a notification is delivered for events matching this rule. pub actions: Vec, @@ -116,7 +116,7 @@ pub struct PatternedPushRule { } /// An action affects if and how a notification is delivered for a matching event. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug)] pub enum Action { /// This causes each matching event to generate a notification. Notify, @@ -229,7 +229,7 @@ impl<'de> Deserialize<'de> for Action { } /// Values for the `set_tweak` action. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "set_tweak", rename_all = "lowercase")] pub enum Tweak { /// A string representing the sound to be played when this notification arrives. @@ -256,7 +256,7 @@ pub enum Tweak { } /// A condition that must apply for an associated push rule's action to be taken. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug)] pub enum PushCondition { /// This is a glob pattern match on a field of the event. EventMatch(EventMatchCondition), @@ -355,7 +355,7 @@ impl<'de> Deserialize<'de> for PushCondition { } /// A push condition that matches a glob pattern match on a field of the event. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "kind", rename = "event_match")] pub struct EventMatchCondition { /// The dot-separated field of the event to match. @@ -369,7 +369,7 @@ pub struct EventMatchCondition { } /// A push condition that matches the current number of members in the room. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "kind", rename = "room_member_count")] pub struct RoomMemberCountCondition { /// A decimal integer optionally prefixed by one of `==`, `<`, `>`, `>=` or `<=`. @@ -381,7 +381,7 @@ pub struct RoomMemberCountCondition { /// A push condition that takes into account the current power levels in the room, ensuring the /// sender of the event has high enough power to trigger the notification. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "kind", rename = "sender_notification_permission")] pub struct SenderNotificationPermissionCondition { /// The field in the power level event the user needs a minimum power level for. diff --git a/src/receipt.rs b/src/receipt.rs index 6b0b9420..f18cd8cd 100644 --- a/src/receipt.rs +++ b/src/receipt.rs @@ -29,7 +29,7 @@ ruma_event! { } /// A collection of receipts. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct Receipts { /// A collection of users who have sent *m.read* receipts for this event. #[serde(default, rename = "m.read")] @@ -42,7 +42,7 @@ pub struct Receipts { pub type UserReceipts = BTreeMap; /// An acknowledgement of an event. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct Receipt { /// The time when the receipt was sent. #[serde( diff --git a/src/room.rs b/src/room.rs index cb93f35a..2bc30294 100644 --- a/src/room.rs +++ b/src/room.rs @@ -28,7 +28,7 @@ pub mod tombstone; pub mod topic; /// Metadata about an image. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct ImageInfo { /// The height of the image in pixels. #[serde(rename = "h", skip_serializing_if = "Option::is_none")] @@ -60,7 +60,7 @@ pub struct ImageInfo { } /// Metadata about a thumbnail. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct ThumbnailInfo { /// The height of the thumbnail in pixels. #[serde(rename = "h", skip_serializing_if = "Option::is_none")] @@ -80,7 +80,7 @@ pub struct ThumbnailInfo { } /// A file sent to a room with end-to-end encryption enabled. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct EncryptedFile { /// The URL to the file. pub url: String, @@ -100,7 +100,7 @@ pub struct EncryptedFile { } /// A [JSON Web Key](https://tools.ietf.org/html/rfc7517#appendix-A.3) object. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct JsonWebKey { /// Key type. Must be `oct`. pub kty: String, diff --git a/src/room/create.rs b/src/room/create.rs index 31ba4896..13593be6 100644 --- a/src/room/create.rs +++ b/src/room/create.rs @@ -32,7 +32,7 @@ ruma_event! { } /// A reference to an old room replaced during a room version upgrade. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct PreviousRoom { /// The ID of the old room. pub room_id: RoomId, diff --git a/src/room/encrypted.rs b/src/room/encrypted.rs index 714052e1..6a616182 100644 --- a/src/room/encrypted.rs +++ b/src/room/encrypted.rs @@ -12,7 +12,7 @@ use crate::{Algorithm, EventType, FromRaw, UnsignedData}; /// /// This type is to be used within a room. For a to-device event, use `EncryptedEventContent` /// directly. -#[derive(Clone, Debug, PartialEq, Serialize)] +#[derive(Clone, Debug, Serialize)] #[serde(tag = "type", rename = "m.room.encrypted")] pub struct EncryptedEvent { /// The event's content. @@ -33,12 +33,12 @@ pub struct EncryptedEvent { pub sender: UserId, /// Additional key-value pairs not signed by the homeserver. - #[serde(skip_serializing_if = "ruma_serde::is_default")] + #[serde(skip_serializing_if = "UnsignedData::is_empty")] pub unsigned: UnsignedData, } /// The payload for `EncryptedEvent`. -#[derive(Clone, Debug, PartialEq, Serialize)] +#[derive(Clone, Debug, Serialize)] #[serde(untagged)] pub enum EncryptedEventContent { /// An event encrypted with *m.olm.v1.curve25519-aes-sha2*. @@ -106,7 +106,7 @@ pub(crate) mod raw { /// /// This type is to be used within a room. For a to-device event, use `EncryptedEventContent` /// directly. - #[derive(Clone, Debug, PartialEq, Deserialize)] + #[derive(Clone, Debug, Deserialize)] pub struct EncryptedEvent { /// The event's content. pub content: EncryptedEventContent, @@ -130,7 +130,7 @@ pub(crate) mod raw { } /// The payload for `EncryptedEvent`. - #[derive(Clone, Debug, PartialEq)] + #[derive(Clone, Debug)] pub enum EncryptedEventContent { /// An event encrypted with *m.olm.v1.curve25519-aes-sha2*. OlmV1Curve25519AesSha2(OlmV1Curve25519AesSha2Content), @@ -192,7 +192,7 @@ pub(crate) mod raw { } /// The payload for `EncryptedEvent` using the *m.olm.v1.curve25519-aes-sha2* algorithm. -#[derive(Clone, Debug, Serialize, PartialEq, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct OlmV1Curve25519AesSha2Content { /// The encryption algorithm used to encrypt this event. pub algorithm: Algorithm, @@ -207,7 +207,7 @@ pub struct OlmV1Curve25519AesSha2Content { /// Ciphertext information holding the ciphertext and message type. /// /// Used for messages encrypted with the *m.olm.v1.curve25519-aes-sha2* algorithm. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct CiphertextInfo { /// The encrypted payload. pub body: String, @@ -218,7 +218,7 @@ pub struct CiphertextInfo { } /// The payload for `EncryptedEvent` using the *m.megolm.v1.aes-sha2* algorithm. -#[derive(Clone, Debug, Serialize, PartialEq, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct MegolmV1AesSha2Content { /// The encryption algorithm used to encrypt this event. pub algorithm: Algorithm, diff --git a/src/room/member.rs b/src/room/member.rs index e1259345..a49fd42c 100644 --- a/src/room/member.rs +++ b/src/room/member.rs @@ -99,7 +99,7 @@ impl_enum! { } /// Information about a third party invitation. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct ThirdPartyInvite { /// A name which can be displayed to represent the user instead of their third party /// identifier. @@ -112,7 +112,7 @@ pub struct ThirdPartyInvite { /// A block of content which has been signed, which servers can use to verify a third party /// invitation. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct SignedContent { /// The invited Matrix user ID. /// @@ -128,7 +128,7 @@ pub struct SignedContent { } /// Translation of the membership change in `m.room.member` event. -#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] pub enum MembershipChange { /// No change. None, diff --git a/src/room/message.rs b/src/room/message.rs index 31a04efe..dedcecdf 100644 --- a/src/room/message.rs +++ b/src/room/message.rs @@ -12,7 +12,7 @@ use crate::{EventType, FromRaw, UnsignedData}; pub mod feedback; /// A message sent to a room. -#[derive(Clone, Debug, PartialEq, Serialize)] +#[derive(Clone, Debug, Serialize)] #[serde(rename = "m.room.message", tag = "type")] pub struct MessageEvent { /// The event's content. @@ -39,7 +39,7 @@ pub struct MessageEvent { /// The payload for `MessageEvent`. #[allow(clippy::large_enum_variant)] -#[derive(Clone, Debug, PartialEq, Serialize)] +#[derive(Clone, Debug, Serialize)] #[serde(untagged)] pub enum MessageEventContent { /// An audio message. @@ -135,7 +135,7 @@ pub(crate) mod raw { use crate::UnsignedData; /// A message sent to a room. - #[derive(Clone, Debug, PartialEq, Deserialize)] + #[derive(Clone, Debug, Deserialize)] pub struct MessageEvent { /// The event's content. pub content: MessageEventContent, @@ -160,7 +160,7 @@ pub(crate) mod raw { /// The payload for `MessageEvent`. #[allow(clippy::large_enum_variant)] - #[derive(Clone, Debug, PartialEq)] + #[derive(Clone, Debug)] pub enum MessageEventContent { /// An audio message. Audio(AudioMessageEventContent), @@ -295,7 +295,7 @@ pub enum MessageType { } /// The payload for an audio message. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "msgtype", rename = "m.audio")] pub struct AudioMessageEventContent { /// The textual representation of this message. @@ -316,7 +316,7 @@ pub struct AudioMessageEventContent { } /// Metadata about an audio clip. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct AudioInfo { /// The duration of the audio in milliseconds. #[serde(skip_serializing_if = "Option::is_none")] @@ -332,7 +332,7 @@ pub struct AudioInfo { } /// The payload for an emote message. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "msgtype", rename = "m.emote")] pub struct EmoteMessageEventContent { /// The emote action to perform. @@ -349,7 +349,7 @@ pub struct EmoteMessageEventContent { } /// The payload for a file message. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "msgtype", rename = "m.file")] pub struct FileMessageEventContent { /// A human-readable description of the file. This is recommended to be the filename of the @@ -375,7 +375,7 @@ pub struct FileMessageEventContent { } /// Metadata about a file. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct FileInfo { /// The mimetype of the file, e.g. "application/msword." #[serde(skip_serializing_if = "Option::is_none")] @@ -399,7 +399,7 @@ pub struct FileInfo { } /// The payload for an image message. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "msgtype", rename = "m.image")] pub struct ImageMessageEventContent { /// A textual representation of the image. This could be the alt text of the image, the filename @@ -421,7 +421,7 @@ pub struct ImageMessageEventContent { } /// The payload for a location message. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "msgtype", rename = "m.location")] pub struct LocationMessageEventContent { /// A description of the location e.g. "Big Ben, London, UK,"or some kind of content description @@ -437,7 +437,7 @@ pub struct LocationMessageEventContent { } /// Thumbnail info associated with a location. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct LocationInfo { /// Metadata about the image referred to in `thumbnail_url` or `thumbnail_file`. #[serde(skip_serializing_if = "Option::is_none")] @@ -455,7 +455,7 @@ pub struct LocationInfo { } /// The payload for a notice message. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "msgtype", rename = "m.notice")] pub struct NoticeMessageEventContent { /// The notice text to send. @@ -477,7 +477,7 @@ pub struct NoticeMessageEventContent { } /// The payload for a server notice message. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "msgtype", rename = "m.server_notice")] pub struct ServerNoticeMessageEventContent { /// A human-readable description of the notice. @@ -500,7 +500,7 @@ pub struct ServerNoticeMessageEventContent { } /// Types of server notices. -#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] pub enum ServerNoticeType { /// The server has exceeded some limit which requires the server administrator to intervene. #[serde(rename = "m.server_notice.usage_limit_reached")] @@ -514,7 +514,7 @@ pub enum ServerNoticeType { } /// Types of usage limits. -#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] pub enum LimitType { /// The server's number of active users in the last 30 days has exceeded the maximum. /// @@ -531,7 +531,7 @@ pub enum LimitType { } /// The payload for a text message. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "msgtype", rename = "m.text")] pub struct TextMessageEventContent { /// The body of the message. @@ -553,7 +553,7 @@ pub struct TextMessageEventContent { } /// The payload for a video message. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "msgtype", rename = "m.video")] pub struct VideoMessageEventContent { /// A description of the video, e.g. "Gangnam Style," or some kind of content description for @@ -575,7 +575,7 @@ pub struct VideoMessageEventContent { } /// Metadata about a video. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct VideoInfo { /// The duration of the video in milliseconds. #[serde(skip_serializing_if = "Option::is_none")] @@ -615,7 +615,7 @@ pub struct VideoInfo { /// Information about related messages for /// [rich replies](https://matrix.org/docs/spec/client_server/r0.5.0#rich-replies). -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct RelatesTo { /// Information about another message being replied to. #[serde(rename = "m.in_reply_to")] @@ -623,7 +623,7 @@ pub struct RelatesTo { } /// Information about the event a "rich reply" is replying to. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct InReplyTo { /// The event being replied to. pub event_id: EventId, diff --git a/src/room/name.rs b/src/room/name.rs index a1eb8166..26de8790 100644 --- a/src/room/name.rs +++ b/src/room/name.rs @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; use crate::{EventType, InvalidInput, TryFromRaw, UnsignedData}; /// A human-friendly room name designed to be displayed to the end-user. -#[derive(Clone, Debug, PartialEq, Serialize)] +#[derive(Clone, Debug, Serialize)] #[serde(rename = "m.room.name", tag = "type")] pub struct NameEvent { /// The event's content. @@ -36,12 +36,12 @@ pub struct NameEvent { pub state_key: String, /// Additional key-value pairs not signed by the homeserver. - #[serde(skip_serializing_if = "ruma_serde::is_default")] + #[serde(skip_serializing_if = "UnsignedData::is_empty")] pub unsigned: UnsignedData, } /// The payload for `NameEvent`. -#[derive(Clone, Debug, PartialEq, Serialize)] +#[derive(Clone, Debug, Serialize)] pub struct NameEventContent { /// The name of the room. This MUST NOT exceed 255 bytes. pub(crate) name: Option, @@ -109,7 +109,7 @@ pub(crate) mod raw { use super::*; /// A human-friendly room name designed to be displayed to the end-user. - #[derive(Clone, Debug, PartialEq, Deserialize)] + #[derive(Clone, Debug, Deserialize)] pub struct NameEvent { /// The event's content. pub content: NameEventContent, @@ -139,7 +139,7 @@ pub(crate) mod raw { } /// The payload of a `NameEvent`. - #[derive(Clone, Debug, PartialEq, Deserialize)] + #[derive(Clone, Debug, Deserialize)] 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/server_acl.rs b/src/room/server_acl.rs index cdd3836b..e0535510 100644 --- a/src/room/server_acl.rs +++ b/src/room/server_acl.rs @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; use crate::{EventType, FromRaw, UnsignedData}; /// An event to indicate which servers are permitted to participate in the room. -#[derive(Clone, Debug, PartialEq, Serialize)] +#[derive(Clone, Debug, Serialize)] #[serde(rename = "m.room.server_acl", tag = "type")] pub struct ServerAclEvent { /// The event's content. @@ -41,7 +41,7 @@ pub struct ServerAclEvent { } /// The payload for `ServerAclEvent`. -#[derive(Clone, Debug, PartialEq, Serialize)] +#[derive(Clone, Debug, Serialize)] pub struct ServerAclEventContent { /// True to allow server names that are IP address literals. False to deny. Defaults to true if /// missing or otherwise not a boolean. @@ -108,7 +108,7 @@ pub(crate) mod raw { use super::*; /// An event to indicate which servers are permitted to participate in the room. - #[derive(Clone, Debug, PartialEq, Deserialize)] + #[derive(Clone, Debug, Deserialize)] pub struct ServerAclEvent { /// The event's content. pub content: ServerAclEventContent, @@ -138,7 +138,7 @@ pub(crate) mod raw { } /// The payload for `ServerAclEvent`. - #[derive(Clone, Debug, PartialEq, Deserialize)] + #[derive(Clone, Debug, Deserialize)] pub struct ServerAclEventContent { /// True to allow server names that are IP address literals. False to deny. Defaults to true /// if missing or otherwise not a boolean. diff --git a/src/room/third_party_invite.rs b/src/room/third_party_invite.rs index a4089ea0..3107dc0d 100644 --- a/src/room/third_party_invite.rs +++ b/src/room/third_party_invite.rs @@ -30,7 +30,7 @@ ruma_event! { } /// A public key for signing a third party invite token. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct PublicKey { /// An optional URL which can be fetched to validate whether the key has been revoked. /// diff --git a/src/room_key_request.rs b/src/room_key_request.rs index eac4501d..fa94a06b 100644 --- a/src/room_key_request.rs +++ b/src/room_key_request.rs @@ -60,7 +60,7 @@ impl_enum! { } /// Information about a requested key. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct RequestedKeyInfo { /// The encryption algorithm the requested key in this event is to be used with. pub algorithm: Algorithm, diff --git a/src/stripped.rs b/src/stripped.rs index 468a1e0c..8297d9de 100644 --- a/src/stripped.rs +++ b/src/stripped.rs @@ -65,7 +65,7 @@ pub enum AnyStrippedStateEvent { } /// A "stripped-down" version of a core state event. -#[derive(Clone, Debug, PartialEq, Serialize)] +#[derive(Clone, Debug, Serialize)] pub struct StrippedStateEvent { /// Data specific to the event type. pub content: C, diff --git a/src/tag.rs b/src/tag.rs index 7c170d92..45e8781b 100644 --- a/src/tag.rs +++ b/src/tag.rs @@ -18,7 +18,7 @@ ruma_event! { } /// Information about a tag. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, 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/to_device.rs b/src/to_device.rs index 841b81f9..966c542f 100644 --- a/src/to_device.rs +++ b/src/to_device.rs @@ -24,7 +24,7 @@ use crate::{ /// To-device versions of events that will appear in the to-device part of a /// sync response. -#[derive(Clone, Debug, PartialEq, Serialize)] +#[derive(Clone, Debug, Serialize)] #[allow(clippy::large_enum_variant)] pub enum AnyToDeviceEvent { /// To-device version of the "m.dummy" event. @@ -51,7 +51,7 @@ pub enum AnyToDeviceEvent { KeyVerificationRequest(ToDeviceVerificationRequest), } -#[derive(Clone, Debug, PartialEq, Serialize)] +#[derive(Clone, Debug, Serialize)] /// To-device event. pub struct ToDeviceEvent { /// The unique identifier for the user who sent this event.