macros: Merge generate_element_with_children!() into generate_element!().
This commit is contained in:
parent
9c598fbdf9
commit
3fb99988d5
13 changed files with 28 additions and 31 deletions
|
@ -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.
|
||||
///
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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: [
|
||||
|
|
|
@ -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])*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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: [
|
||||
|
|
|
@ -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: [
|
||||
|
|
|
@ -60,7 +60,7 @@ generate_element!(
|
|||
]
|
||||
);
|
||||
|
||||
generate_element_with_children!(
|
||||
generate_element!(
|
||||
Failed, "failed", SM,
|
||||
attributes: [
|
||||
h: Option<u32> = "h" => optional,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use iq::{IqGetPayload, IqResultPayload};
|
||||
|
||||
generate_element_with_children!(
|
||||
generate_element!(
|
||||
Version, "query", VERSION,
|
||||
children: [
|
||||
name: Required<String> = ("name", VERSION) => String,
|
||||
|
|
Loading…
Reference in a new issue