xmpp-parsers: Make everything PartialEq! \o/

This commit is contained in:
Emmanuel Gil Peyrot 2020-11-29 21:17:51 +01:00
commit 923a054b81
15 changed files with 21 additions and 25 deletions

View file

@ -14,7 +14,7 @@ use std::str::FromStr;
/// ///
/// The text value SHOULD be of the form algo+hash@bob.xmpp.org, this struct /// The text value SHOULD be of the form algo+hash@bob.xmpp.org, this struct
/// enforces that format. /// enforces that format.
#[derive(Clone, Debug)] #[derive(Clone, Debug, PartialEq)]
pub struct ContentId { pub struct ContentId {
hash: Hash, hash: Hash,
} }

View file

@ -69,7 +69,7 @@ generate_attribute!(
); );
/// Represents a field in a [data form](struct.DataForm.html). /// Represents a field in a [data form](struct.DataForm.html).
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct Field { pub struct Field {
/// The unique identifier for this field, in the form. /// The unique identifier for this field, in the form.
pub var: String, pub var: String,
@ -187,7 +187,7 @@ generate_attribute!(
); );
/// This is a form to be sent to another entity for filling. /// This is a form to be sent to another entity for filling.
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct DataForm { pub struct DataForm {
/// The type of this form, telling the other party which action to execute. /// The type of this form, telling the other party which action to execute.
pub type_: DataFormType, pub type_: DataFormType,

View file

@ -27,7 +27,6 @@ impl IqGetPayload for DiscoInfoQuery {}
generate_element!( generate_element!(
/// Structure representing a `<feature xmlns='http://jabber.org/protocol/disco#info'/>` element. /// Structure representing a `<feature xmlns='http://jabber.org/protocol/disco#info'/>` element.
#[derive(PartialEq)]
Feature, "feature", DISCO_INFO, Feature, "feature", DISCO_INFO,
attributes: [ attributes: [
/// Namespace of the feature we want to represent. /// Namespace of the feature we want to represent.

View file

@ -97,7 +97,6 @@ impl IntoAttributeValue for Algo {
generate_element!( generate_element!(
/// This element represents a hash of some data, defined by the hash /// This element represents a hash of some data, defined by the hash
/// algorithm used and the computed value. /// algorithm used and the computed value.
#[derive(PartialEq)]
Hash, "hash", HASHES, Hash, "hash", HASHES,
attributes: [ attributes: [
/// The algorithm used to create this hash. /// The algorithm used to create this hash.

View file

@ -171,7 +171,7 @@ generate_id!(
); );
/// Enum wrapping all of the various supported descriptions of a Content. /// Enum wrapping all of the various supported descriptions of a Content.
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub enum Description { pub enum Description {
/// Jingle RTP Sessions (XEP-0167) description. /// Jingle RTP Sessions (XEP-0167) description.
Rtp(RtpDescription), Rtp(RtpDescription),
@ -208,7 +208,7 @@ impl From<Description> for Element {
} }
/// Enum wrapping all of the various supported transports of a Content. /// Enum wrapping all of the various supported transports of a Content.
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub enum Transport { pub enum Transport {
/// Jingle ICE-UDP Bytestreams (XEP-0176) transport. /// Jingle ICE-UDP Bytestreams (XEP-0176) transport.
IceUdp(IceUdpTransport), IceUdp(IceUdpTransport),
@ -465,7 +465,7 @@ impl From<Reason> for Element {
type Lang = String; type Lang = String;
/// Informs the recipient of something. /// Informs the recipient of something.
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct ReasonElement { pub struct ReasonElement {
/// The list of possible reasons to be included in a Jingle iq. /// The list of possible reasons to be included in a Jingle iq.
pub reason: Reason, pub reason: Reason,
@ -541,7 +541,7 @@ generate_id!(
); );
/// The main Jingle container, to be included in an iq stanza. /// The main Jingle container, to be included in an iq stanza.
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct Jingle { pub struct Jingle {
/// The action to execute on both ends. /// The action to execute on both ends.
pub action: Action, pub action: Action,

View file

@ -16,7 +16,7 @@ use std::str::FromStr;
generate_element!( generate_element!(
/// Represents a range in a file. /// Represents a range in a file.
#[derive(PartialEq, Default)] #[derive(Default)]
Range, "range", JINGLE_FT, Range, "range", JINGLE_FT,
attributes: [ attributes: [
/// The offset in bytes from the beginning of the file. /// The offset in bytes from the beginning of the file.

View file

@ -18,7 +18,6 @@ generate_attribute!(
); );
generate_element!( generate_element!(
#[derive(PartialEq)]
/// Describes a content that should be grouped with other ones. /// Describes a content that should be grouped with other ones.
Content, "content", JINGLE_GROUPING, Content, "content", JINGLE_GROUPING,
attributes: [ attributes: [

View file

@ -102,7 +102,7 @@ impl Candidate {
} }
/// The payload of a transport. /// The payload of a transport.
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub enum TransportPayload { pub enum TransportPayload {
/// The responder informs the initiator that the bytestream pointed by this /// The responder informs the initiator that the bytestream pointed by this
/// candidate has been activated. /// candidate has been activated.
@ -126,7 +126,7 @@ pub enum TransportPayload {
} }
/// Describes a Jingle transport using a direct or proxied connection. /// Describes a Jingle transport using a direct or proxied connection.
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct Transport { pub struct Transport {
/// The stream identifier for this transport. /// The stream identifier for this transport.
pub sid: StreamId, pub sid: StreamId,

View file

@ -61,7 +61,7 @@ generate_elem_id!(
); );
/// The main structure representing the `<message/>` stanza. /// The main structure representing the `<message/>` stanza.
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct Message { pub struct Message {
/// The JID emitting this stanza. /// The JID emitting this stanza.
pub from: Option<Jid>, pub from: Option<Jid>,

View file

@ -10,7 +10,7 @@ use crate::presence::PresencePayload;
generate_element!( generate_element!(
/// Represents the query for messages before our join. /// Represents the query for messages before our join.
#[derive(PartialEq, Default)] #[derive(Default)]
History, "history", MUC, History, "history", MUC,
attributes: [ attributes: [
/// How many characters of history to send, in XML characters. /// How many characters of history to send, in XML characters.
@ -60,7 +60,7 @@ impl History {
generate_element!( generate_element!(
/// Represents a room join request. /// Represents a room join request.
#[derive(PartialEq, Default)] #[derive(Default)]
Muc, "x", MUC, children: [ Muc, "x", MUC, children: [
/// Password to use when the room is protected by a password. /// Password to use when the room is protected by a password.
password: Option<String> = ("password", MUC) => String, password: Option<String> = ("password", MUC) => String,

View file

@ -49,7 +49,7 @@ generate_attribute!(
); );
/// An item from a PubSub node. /// An item from a PubSub node.
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct Item { pub struct Item {
/// The identifier for this item, unique per node. /// The identifier for this item, unique per node.
pub id: Option<ItemId>, pub id: Option<ItemId>,

View file

@ -126,7 +126,7 @@ impl Items {
} }
/// Response wrapper for a PubSub `<item/>`. /// Response wrapper for a PubSub `<item/>`.
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct Item(pub PubSubItem); pub struct Item(pub PubSubItem);
impl_pubsub_item!(Item, PUBSUB); impl_pubsub_item!(Item, PUBSUB);
@ -196,7 +196,7 @@ generate_element!(
); );
/// Indicate that the subscription can be configured. /// Indicate that the subscription can be configured.
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct SubscribeOptions { pub struct SubscribeOptions {
/// If `true`, the configuration is actually required. /// If `true`, the configuration is actually required.
required: bool, required: bool,
@ -304,7 +304,7 @@ generate_element!(
/// Main payload used to communicate with a PubSub service. /// Main payload used to communicate with a PubSub service.
/// ///
/// `<pubsub xmlns="http://jabber.org/protocol/pubsub"/>` /// `<pubsub xmlns="http://jabber.org/protocol/pubsub"/>`
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub enum PubSub { pub enum PubSub {
/// Request to create a new node, with optional suggested name and suggested configuration. /// Request to create a new node, with optional suggested name and suggested configuration.
Create { Create {

View file

@ -46,7 +46,6 @@ generate_attribute!(
generate_element!( generate_element!(
/// Contact from the users contact list. /// Contact from the users contact list.
#[derive(PartialEq)]
Item, "item", ROSTER, Item, "item", ROSTER,
attributes: [ attributes: [
/// JID of this contact. /// JID of this contact.

View file

@ -11,7 +11,7 @@ use std::convert::TryFrom;
/// Requests paging through a potentially big set of items (represented by an /// Requests paging through a potentially big set of items (represented by an
/// UID). /// UID).
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct SetQuery { pub struct SetQuery {
/// Limit the number of items, or use the recipients defaults if None. /// Limit the number of items, or use the recipients defaults if None.
pub max: Option<usize>, pub max: Option<usize>,
@ -92,7 +92,7 @@ impl From<SetQuery> for Element {
} }
/// Describes the paging result of a [query](struct.SetQuery.html). /// Describes the paging result of a [query](struct.SetQuery.html).
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct SetResult { pub struct SetResult {
/// The UID of the first item of the page. /// The UID of the first item of the page.
pub first: Option<String>, pub first: Option<String>,

View file

@ -370,7 +370,7 @@ macro_rules! check_no_unknown_attributes {
macro_rules! generate_empty_element { macro_rules! generate_empty_element {
($(#[$meta:meta])* $elem:ident, $name:tt, $ns:ident) => ( ($(#[$meta:meta])* $elem:ident, $name:tt, $ns:ident) => (
$(#[$meta])* $(#[$meta])*
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct $elem; pub struct $elem;
impl ::std::convert::TryFrom<crate::Element> for $elem { impl ::std::convert::TryFrom<crate::Element> 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: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])* $(#[$meta])*
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct $elem { pub struct $elem {
$( $(
$(#[$attr_meta])* $(#[$attr_meta])*