From 923a054b81a28c320437cdd25af95f9609c31dac Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 29 Nov 2020 21:17:51 +0100 Subject: [PATCH] xmpp-parsers: Make everything PartialEq! \o/ --- xmpp-parsers/src/bob.rs | 2 +- xmpp-parsers/src/data_forms.rs | 4 ++-- xmpp-parsers/src/disco.rs | 1 - xmpp-parsers/src/hashes.rs | 1 - xmpp-parsers/src/jingle.rs | 8 ++++---- xmpp-parsers/src/jingle_ft.rs | 2 +- xmpp-parsers/src/jingle_grouping.rs | 1 - xmpp-parsers/src/jingle_s5b.rs | 4 ++-- xmpp-parsers/src/message.rs | 2 +- xmpp-parsers/src/muc/muc.rs | 4 ++-- xmpp-parsers/src/pubsub/mod.rs | 2 +- xmpp-parsers/src/pubsub/pubsub.rs | 6 +++--- xmpp-parsers/src/roster.rs | 1 - xmpp-parsers/src/rsm.rs | 4 ++-- xmpp-parsers/src/util/macros.rs | 4 ++-- 15 files changed, 21 insertions(+), 25 deletions(-) diff --git a/xmpp-parsers/src/bob.rs b/xmpp-parsers/src/bob.rs index e6756440..101a7490 100644 --- a/xmpp-parsers/src/bob.rs +++ b/xmpp-parsers/src/bob.rs @@ -14,7 +14,7 @@ use std::str::FromStr; /// /// The text value SHOULD be of the form algo+hash@bob.xmpp.org, this struct /// enforces that format. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] pub struct ContentId { hash: Hash, } diff --git a/xmpp-parsers/src/data_forms.rs b/xmpp-parsers/src/data_forms.rs index 11603b3e..596a3176 100644 --- a/xmpp-parsers/src/data_forms.rs +++ b/xmpp-parsers/src/data_forms.rs @@ -69,7 +69,7 @@ generate_attribute!( ); /// Represents a field in a [data form](struct.DataForm.html). -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct Field { /// The unique identifier for this field, in the form. pub var: String, @@ -187,7 +187,7 @@ generate_attribute!( ); /// This is a form to be sent to another entity for filling. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct DataForm { /// The type of this form, telling the other party which action to execute. pub type_: DataFormType, diff --git a/xmpp-parsers/src/disco.rs b/xmpp-parsers/src/disco.rs index 6ed2c13f..3a1890d7 100644 --- a/xmpp-parsers/src/disco.rs +++ b/xmpp-parsers/src/disco.rs @@ -27,7 +27,6 @@ impl IqGetPayload for DiscoInfoQuery {} generate_element!( /// Structure representing a `` element. -#[derive(PartialEq)] Feature, "feature", DISCO_INFO, attributes: [ /// Namespace of the feature we want to represent. diff --git a/xmpp-parsers/src/hashes.rs b/xmpp-parsers/src/hashes.rs index 964719f0..704af523 100644 --- a/xmpp-parsers/src/hashes.rs +++ b/xmpp-parsers/src/hashes.rs @@ -97,7 +97,6 @@ impl IntoAttributeValue for Algo { generate_element!( /// This element represents a hash of some data, defined by the hash /// algorithm used and the computed value. - #[derive(PartialEq)] Hash, "hash", HASHES, attributes: [ /// The algorithm used to create this hash. diff --git a/xmpp-parsers/src/jingle.rs b/xmpp-parsers/src/jingle.rs index 78888769..f4d84009 100644 --- a/xmpp-parsers/src/jingle.rs +++ b/xmpp-parsers/src/jingle.rs @@ -171,7 +171,7 @@ generate_id!( ); /// Enum wrapping all of the various supported descriptions of a Content. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub enum Description { /// Jingle RTP Sessions (XEP-0167) description. Rtp(RtpDescription), @@ -208,7 +208,7 @@ impl From for Element { } /// Enum wrapping all of the various supported transports of a Content. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub enum Transport { /// Jingle ICE-UDP Bytestreams (XEP-0176) transport. IceUdp(IceUdpTransport), @@ -465,7 +465,7 @@ impl From for Element { type Lang = String; /// Informs the recipient of something. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct ReasonElement { /// The list of possible reasons to be included in a Jingle iq. pub reason: Reason, @@ -541,7 +541,7 @@ generate_id!( ); /// The main Jingle container, to be included in an iq stanza. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct Jingle { /// The action to execute on both ends. pub action: Action, diff --git a/xmpp-parsers/src/jingle_ft.rs b/xmpp-parsers/src/jingle_ft.rs index 85ab5ec6..d44b7e17 100644 --- a/xmpp-parsers/src/jingle_ft.rs +++ b/xmpp-parsers/src/jingle_ft.rs @@ -16,7 +16,7 @@ use std::str::FromStr; generate_element!( /// Represents a range in a file. - #[derive(PartialEq, Default)] + #[derive(Default)] Range, "range", JINGLE_FT, attributes: [ /// The offset in bytes from the beginning of the file. diff --git a/xmpp-parsers/src/jingle_grouping.rs b/xmpp-parsers/src/jingle_grouping.rs index 310e09c3..01c882d9 100644 --- a/xmpp-parsers/src/jingle_grouping.rs +++ b/xmpp-parsers/src/jingle_grouping.rs @@ -18,7 +18,6 @@ generate_attribute!( ); generate_element!( - #[derive(PartialEq)] /// Describes a content that should be grouped with other ones. Content, "content", JINGLE_GROUPING, attributes: [ diff --git a/xmpp-parsers/src/jingle_s5b.rs b/xmpp-parsers/src/jingle_s5b.rs index 10634d0f..e481f56f 100644 --- a/xmpp-parsers/src/jingle_s5b.rs +++ b/xmpp-parsers/src/jingle_s5b.rs @@ -102,7 +102,7 @@ impl Candidate { } /// The payload of a transport. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub enum TransportPayload { /// The responder informs the initiator that the bytestream pointed by this /// candidate has been activated. @@ -126,7 +126,7 @@ pub enum TransportPayload { } /// Describes a Jingle transport using a direct or proxied connection. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct Transport { /// The stream identifier for this transport. pub sid: StreamId, diff --git a/xmpp-parsers/src/message.rs b/xmpp-parsers/src/message.rs index f473010d..281543a2 100644 --- a/xmpp-parsers/src/message.rs +++ b/xmpp-parsers/src/message.rs @@ -61,7 +61,7 @@ generate_elem_id!( ); /// The main structure representing the `` stanza. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct Message { /// The JID emitting this stanza. pub from: Option, diff --git a/xmpp-parsers/src/muc/muc.rs b/xmpp-parsers/src/muc/muc.rs index ef5186db..edce3038 100644 --- a/xmpp-parsers/src/muc/muc.rs +++ b/xmpp-parsers/src/muc/muc.rs @@ -10,7 +10,7 @@ use crate::presence::PresencePayload; generate_element!( /// Represents the query for messages before our join. - #[derive(PartialEq, Default)] + #[derive(Default)] History, "history", MUC, attributes: [ /// How many characters of history to send, in XML characters. @@ -60,7 +60,7 @@ impl History { generate_element!( /// Represents a room join request. - #[derive(PartialEq, Default)] + #[derive(Default)] Muc, "x", MUC, children: [ /// Password to use when the room is protected by a password. password: Option = ("password", MUC) => String, diff --git a/xmpp-parsers/src/pubsub/mod.rs b/xmpp-parsers/src/pubsub/mod.rs index ee668ffb..e639c28a 100644 --- a/xmpp-parsers/src/pubsub/mod.rs +++ b/xmpp-parsers/src/pubsub/mod.rs @@ -49,7 +49,7 @@ generate_attribute!( ); /// An item from a PubSub node. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct Item { /// The identifier for this item, unique per node. pub id: Option, diff --git a/xmpp-parsers/src/pubsub/pubsub.rs b/xmpp-parsers/src/pubsub/pubsub.rs index d4ad9f81..6184e402 100644 --- a/xmpp-parsers/src/pubsub/pubsub.rs +++ b/xmpp-parsers/src/pubsub/pubsub.rs @@ -126,7 +126,7 @@ impl Items { } /// Response wrapper for a PubSub ``. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct Item(pub PubSubItem); impl_pubsub_item!(Item, PUBSUB); @@ -196,7 +196,7 @@ generate_element!( ); /// Indicate that the subscription can be configured. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct SubscribeOptions { /// If `true`, the configuration is actually required. required: bool, @@ -304,7 +304,7 @@ generate_element!( /// Main payload used to communicate with a PubSub service. /// /// `` -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub enum PubSub { /// Request to create a new node, with optional suggested name and suggested configuration. Create { diff --git a/xmpp-parsers/src/roster.rs b/xmpp-parsers/src/roster.rs index cdf83685..16952961 100644 --- a/xmpp-parsers/src/roster.rs +++ b/xmpp-parsers/src/roster.rs @@ -46,7 +46,6 @@ generate_attribute!( generate_element!( /// Contact from the user’s contact list. - #[derive(PartialEq)] Item, "item", ROSTER, attributes: [ /// JID of this contact. diff --git a/xmpp-parsers/src/rsm.rs b/xmpp-parsers/src/rsm.rs index 4efb8bcf..f5649c71 100644 --- a/xmpp-parsers/src/rsm.rs +++ b/xmpp-parsers/src/rsm.rs @@ -11,7 +11,7 @@ use std::convert::TryFrom; /// Requests paging through a potentially big set of items (represented by an /// UID). -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct SetQuery { /// Limit the number of items, or use the recipient’s defaults if None. pub max: Option, @@ -92,7 +92,7 @@ impl From for Element { } /// Describes the paging result of a [query](struct.SetQuery.html). -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct SetResult { /// The UID of the first item of the page. pub first: Option, diff --git a/xmpp-parsers/src/util/macros.rs b/xmpp-parsers/src/util/macros.rs index 16d2c406..702a16f1 100644 --- a/xmpp-parsers/src/util/macros.rs +++ b/xmpp-parsers/src/util/macros.rs @@ -370,7 +370,7 @@ macro_rules! check_no_unknown_attributes { macro_rules! generate_empty_element { ($(#[$meta:meta])* $elem:ident, $name:tt, $ns:ident) => ( $(#[$meta])* - #[derive(Debug, Clone)] + #[derive(Debug, Clone, PartialEq)] pub struct $elem; impl ::std::convert::TryFrom for $elem { @@ -642,7 +642,7 @@ macro_rules! generate_element { ); ($(#[$meta:meta])* $elem:ident, $name:tt, $ns:ident, attributes: [$($(#[$attr_meta:meta])* $attr:ident: $attr_action:tt<$attr_type:ty> = $attr_name:tt),*], children: [$($(#[$child_meta:meta])* $child_ident:ident: $coucou:tt<$child_type:ty> = ($child_name:tt, $child_ns:tt) => $child_constructor:ident),*] $(, text: ($(#[$text_meta:meta])* $text_ident:ident: $codec:ident < $text_type:ty >))*) => ( $(#[$meta])* - #[derive(Debug, Clone)] + #[derive(Debug, Clone, PartialEq)] pub struct $elem { $( $(#[$attr_meta])*