macros: Merge generate_element_with_children!() into generate_element!().

Emmanuel Gil Peyrot created

Change summary

src/disco.rs         |  2 +-
src/ecaps2.rs        |  2 +-
src/jingle.rs        |  2 +-
src/jingle_ft.rs     |  2 +-
src/macros.rs        | 11 ++++-------
src/mam.rs           |  6 +++---
src/media_element.rs |  2 +-
src/muc/muc.rs       |  2 +-
src/muc/user.rs      |  4 ++--
src/pubsub/pubsub.rs | 18 +++++++++---------
src/roster.rs        |  4 ++--
src/sm.rs            |  2 +-
src/version.rs       |  2 +-
13 files changed, 28 insertions(+), 31 deletions(-)

Detailed changes

src/disco.rs πŸ”—

@@ -212,7 +212,7 @@ attributes: [
     name: Option<String> = "name" => optional,
 ]);
 
-generate_element_with_children!(
+generate_element!(
     /// Structure representing a `<query
     /// xmlns='http://jabber.org/protocol/disco#items'/>` element.
     ///

src/ecaps2.rs πŸ”—

@@ -16,7 +16,7 @@ use sha3::{Sha3_256, Sha3_512};
 use blake2::Blake2b;
 use digest::{Digest, VariableOutput};
 
-generate_element_with_children!(
+generate_element!(
     ECaps2, "c", ECAPS2,
     children: [
         hashes: Vec<Hash> = ("hash", HASHES) => Hash

src/jingle.rs πŸ”—

@@ -66,7 +66,7 @@ generate_attribute!(Disposition, "disposition", {
 
 generate_id!(ContentId);
 
-generate_element_with_children!(
+generate_element!(
     Content, "content", JINGLE,
     attributes: [
         creator: Creator = "creator" => required,

src/jingle_ft.rs πŸ”—

@@ -18,7 +18,7 @@ use minidom::Element;
 use error::Error;
 use ns;
 
-generate_element_with_children!(
+generate_element!(
     #[derive(PartialEq, Default)]
     Range, "range", JINGLE_FT,
     attributes: [

src/macros.rs πŸ”—

@@ -466,19 +466,16 @@ macro_rules! generate_serialiser {
 
 macro_rules! generate_element {
     ($(#[$meta:meta])* $elem:ident, $name:tt, $ns:ident, attributes: [$($(#[$attr_meta:meta])* $attr:ident: $attr_type:ty = $attr_name:tt => $attr_action:tt),+,]) => (
-        generate_element_with_children!($(#[$meta])* $elem, $name, $ns, attributes: [$($(#[$attr_meta])* $attr: $attr_type = $attr_name => $attr_action),*], children: []);
+        generate_element!($(#[$meta])* $elem, $name, $ns, attributes: [$($(#[$attr_meta])* $attr: $attr_type = $attr_name => $attr_action),*], children: []);
     );
     ($(#[$meta:meta])* $elem:ident, $name:tt, $ns:ident, attributes: [$($(#[$attr_meta:meta])* $attr:ident: $attr_type:ty = $attr_name:tt => $attr_action:tt),+]) => (
-        generate_element_with_children!($(#[$meta])* $elem, $name, $ns, attributes: [$($(#[$attr_meta])* $attr: $attr_type = $attr_name => $attr_action),*], children: []);
+        generate_element!($(#[$meta])* $elem, $name, $ns, attributes: [$($(#[$attr_meta])* $attr: $attr_type = $attr_name => $attr_action),*], children: []);
     );
-}
-
-macro_rules! generate_element_with_children {
     ($(#[$meta:meta])* $elem:ident, $name:tt, $ns:ident, children: [$($(#[$child_meta:meta])* $child_ident:ident: $coucou:tt<$child_type:ty> = ($child_name:tt, $child_ns:ident) => $child_constructor:ident),*]) => (
-        generate_element_with_children!($(#[$meta])* $elem, $name, $ns, attributes: [], children: [$($(#[$child_meta])* $child_ident: $coucou<$child_type> = ($child_name, $child_ns) => $child_constructor),*]);
+        generate_element!($(#[$meta])* $elem, $name, $ns, attributes: [], children: [$($(#[$child_meta])* $child_ident: $coucou<$child_type> = ($child_name, $child_ns) => $child_constructor),*]);
     );
     ($(#[$meta:meta])* $elem:ident, $name:tt, $ns:ident, attributes: [$($(#[$attr_meta:meta])* $attr:ident: $attr_type:ty = $attr_name:tt => $attr_action:tt),*,], children: [$($(#[$child_meta:meta])* $child_ident:ident: $coucou:tt<$child_type:ty> = ($child_name:tt, $child_ns:ident) => $child_constructor:ident),*]) => (
-        generate_element_with_children!($(#[$meta])* $elem, $name, $ns, attributes: [$($(#[$attr_meta])* $attr: $attr_type = $attr_name => $attr_action),*], children: [$($(#[$child_meta])* $child_ident: $coucou<$child_type> = ($child_name, $child_ns) => $child_constructor),*]);
+        generate_element!($(#[$meta])* $elem, $name, $ns, attributes: [$($(#[$attr_meta])* $attr: $attr_type = $attr_name => $attr_action),*], children: [$($(#[$child_meta])* $child_ident: $coucou<$child_type> = ($child_name, $child_ns) => $child_constructor),*]);
     );
     ($(#[$meta:meta])* $elem:ident, $name:tt, $ns:ident, attributes: [$($(#[$attr_meta:meta])* $attr:ident: $attr_type:ty = $attr_name:tt => $attr_action:tt),*], children: [$($(#[$child_meta:meta])* $child_ident:ident: $coucou:tt<$child_type:ty> = ($child_name:tt, $child_ns:ident) => $child_constructor:ident),*]) => (
         $(#[$meta])*

src/mam.rs πŸ”—

@@ -18,7 +18,7 @@ use forwarding::Forwarded;
 
 use ns;
 
-generate_element_with_children!(
+generate_element!(
     Query, "query", MAM,
     attributes: [
         queryid: Option<String> = "queryid" => optional,
@@ -34,7 +34,7 @@ impl IqGetPayload for Query {}
 impl IqSetPayload for Query {}
 impl IqResultPayload for Query {}
 
-generate_element_with_children!(
+generate_element!(
     Result_, "result", MAM,
     attributes: [
         id: String = "id" => required,
@@ -49,7 +49,7 @@ generate_attribute!(
     Complete, "complete", bool
 );
 
-generate_element_with_children!(
+generate_element!(
     Fin, "fin", MAM,
     attributes: [
         complete: Complete = "complete" => default

src/media_element.rs πŸ”—

@@ -13,7 +13,7 @@ generate_element_with_text!(URI, "uri", MEDIA_ELEMENT,
     uri: TrimmedPlainText<String>
 );
 
-generate_element_with_children!(MediaElement, "media", MEDIA_ELEMENT,
+generate_element!(MediaElement, "media", MEDIA_ELEMENT,
     attributes: [
         width: Option<usize> = "width" => optional,
         height: Option<usize> = "height" => optional

src/muc/muc.rs πŸ”—

@@ -5,7 +5,7 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-generate_element_with_children!(
+generate_element!(
     Muc, "x", MUC, children: [
         password: Option<String> = ("password", MUC) => String
     ]

src/muc/user.rs πŸ”—

@@ -142,7 +142,7 @@ generate_attribute!(Role, "role", {
     None => "none",
 }, Default = None);
 
-generate_element_with_children!(
+generate_element!(
     Item, "item", MUC_USER, attributes: [
         affiliation: Affiliation = "affiliation" => required,
         jid: Option<Jid> = "jid" => optional,
@@ -155,7 +155,7 @@ generate_element_with_children!(
     ]
 );
 
-generate_element_with_children!(
+generate_element!(
     MucUser, "x", MUC_USER, children: [
         status: Vec<Status> = ("status", MUC_USER) => Status,
         items: Vec<Item> = ("item", MUC_USER) => Item

src/pubsub/pubsub.rs πŸ”—

@@ -22,7 +22,7 @@ use pubsub::{NodeName, ItemId, Subscription, SubscriptionId};
 
 // TODO: a better solution would be to split this into a query and a result elements, like for
 // XEP-0030.
-generate_element_with_children!(
+generate_element!(
     /// A list of affiliations you have on a service, or on a node.
     Affiliations, "affiliations", PUBSUB,
     attributes: [
@@ -70,7 +70,7 @@ generate_element!(
     ]
 );
 
-generate_element_with_children!(
+generate_element!(
     /// Request to configure a new node.
     Configure, "configure", PUBSUB,
     children: [
@@ -100,7 +100,7 @@ generate_element!(
     ]
 );
 
-generate_element_with_children!(
+generate_element!(
     /// A request for a list of items.
     Items, "items", PUBSUB,
     attributes: [
@@ -158,7 +158,7 @@ impl From<Item> for Element {
     }
 }
 
-generate_element_with_children!(
+generate_element!(
     /// The options associated to a subscription request.
     Options, "options", PUBSUB,
     attributes: [
@@ -177,7 +177,7 @@ generate_element_with_children!(
     ]
 );
 
-generate_element_with_children!(
+generate_element!(
     /// Request to publish items to a node.
     Publish, "publish", PUBSUB,
     attributes: [
@@ -190,7 +190,7 @@ generate_element_with_children!(
     ]
 );
 
-generate_element_with_children!(
+generate_element!(
     /// The options associated to a publish request.
     PublishOptions, "publish-options", PUBSUB,
     children: [
@@ -204,7 +204,7 @@ generate_attribute!(
     Notify, "notify", bool
 );
 
-generate_element_with_children!(
+generate_element!(
     /// A request to retract some items from a node.
     Retract, "retract", PUBSUB,
     attributes: [
@@ -275,7 +275,7 @@ generate_element!(
     ]
 );
 
-generate_element_with_children!(
+generate_element!(
     /// A request for current subscriptions.
     Subscriptions, "subscriptions", PUBSUB,
     attributes: [
@@ -288,7 +288,7 @@ generate_element_with_children!(
     ]
 );
 
-generate_element_with_children!(
+generate_element!(
     /// A subscription element, describing the state of a subscription.
     SubscriptionElem, "subscription", PUBSUB,
     attributes: [

src/roster.rs πŸ”—

@@ -17,7 +17,7 @@ generate_attribute!(Subscription, "subscription", {
     Remove => "remove",
 }, Default = None);
 
-generate_element_with_children!(
+generate_element!(
     /// Contact from the user’s contact list.
     #[derive(PartialEq)]
     Item, "item", ROSTER,
@@ -38,7 +38,7 @@ generate_element_with_children!(
     ]
 );
 
-generate_element_with_children!(
+generate_element!(
     /// The contact list of the user.
     Roster, "query", ROSTER,
     attributes: [

src/sm.rs πŸ”—

@@ -60,7 +60,7 @@ generate_element!(
     ]
 );
 
-generate_element_with_children!(
+generate_element!(
     Failed, "failed", SM,
     attributes: [
         h: Option<u32> = "h" => optional,

src/version.rs πŸ”—

@@ -6,7 +6,7 @@
 
 use iq::{IqGetPayload, IqResultPayload};
 
-generate_element_with_children!(
+generate_element!(
     Version, "query", VERSION,
     children: [
         name: Required<String> = ("name", VERSION) => String,