diff --git a/src/disco.rs b/src/disco.rs index 679b06e5..b6b653c5 100644 --- a/src/disco.rs +++ b/src/disco.rs @@ -212,7 +212,7 @@ attributes: [ name: Option = "name" => optional, ]); -generate_element_with_children!( +generate_element!( /// Structure representing a `` element. /// diff --git a/src/ecaps2.rs b/src/ecaps2.rs index b96585bc..4caa7d35 100644 --- a/src/ecaps2.rs +++ b/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", HASHES) => Hash diff --git a/src/jingle.rs b/src/jingle.rs index 951a2fa1..1600fed1 100644 --- a/src/jingle.rs +++ b/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, diff --git a/src/jingle_ft.rs b/src/jingle_ft.rs index b9e1d3ef..4cb0fa52 100644 --- a/src/jingle_ft.rs +++ b/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: [ diff --git a/src/macros.rs b/src/macros.rs index 9b950104..48a2702d 100644 --- a/src/macros.rs +++ b/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])* diff --git a/src/mam.rs b/src/mam.rs index b835fc50..b1965667 100644 --- a/src/mam.rs +++ b/src/mam.rs @@ -18,7 +18,7 @@ use forwarding::Forwarded; use ns; -generate_element_with_children!( +generate_element!( Query, "query", MAM, attributes: [ queryid: Option = "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 diff --git a/src/media_element.rs b/src/media_element.rs index 43f0d7ac..9b9133c5 100644 --- a/src/media_element.rs +++ b/src/media_element.rs @@ -13,7 +13,7 @@ generate_element_with_text!(URI, "uri", MEDIA_ELEMENT, uri: TrimmedPlainText ); -generate_element_with_children!(MediaElement, "media", MEDIA_ELEMENT, +generate_element!(MediaElement, "media", MEDIA_ELEMENT, attributes: [ width: Option = "width" => optional, height: Option = "height" => optional diff --git a/src/muc/muc.rs b/src/muc/muc.rs index 80905a20..355b089f 100644 --- a/src/muc/muc.rs +++ b/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 = ("password", MUC) => String ] diff --git a/src/muc/user.rs b/src/muc/user.rs index 15cea9e4..8baa6271 100644 --- a/src/muc/user.rs +++ b/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" => optional, @@ -155,7 +155,7 @@ generate_element_with_children!( ] ); -generate_element_with_children!( +generate_element!( MucUser, "x", MUC_USER, children: [ status: Vec = ("status", MUC_USER) => Status, items: Vec = ("item", MUC_USER) => Item diff --git a/src/pubsub/pubsub.rs b/src/pubsub/pubsub.rs index 807ce908..8ecb89b6 100644 --- a/src/pubsub/pubsub.rs +++ b/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 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: [ diff --git a/src/roster.rs b/src/roster.rs index e851c485..bbd0c399 100644 --- a/src/roster.rs +++ b/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: [ diff --git a/src/sm.rs b/src/sm.rs index 3558c8e7..20e9fc61 100644 --- a/src/sm.rs +++ b/src/sm.rs @@ -60,7 +60,7 @@ generate_element!( ] ); -generate_element_with_children!( +generate_element!( Failed, "failed", SM, attributes: [ h: Option = "h" => optional, diff --git a/src/version.rs b/src/version.rs index 94cfcbb2..1265c162 100644 --- a/src/version.rs +++ b/src/version.rs @@ -6,7 +6,7 @@ use iq::{IqGetPayload, IqResultPayload}; -generate_element_with_children!( +generate_element!( Version, "query", VERSION, children: [ name: Required = ("name", VERSION) => String,