diff --git a/parsers/src/attention.rs b/parsers/src/attention.rs
index df59e14..0f2de0e 100644
--- a/parsers/src/attention.rs
+++ b/parsers/src/attention.rs
@@ -3,15 +3,15 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// 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/.
+use xso::{FromXml, IntoXml};
use crate::message::MessagePayload;
+use crate::ns;
-generate_empty_element!(
- /// Requests the attention of the recipient.
- Attention,
- "attention",
- ATTENTION
-);
+/// Requests the attention of the recipient.
+#[derive(FromXml, IntoXml, Debug, Clone, PartialEq)]
+#[xml(namespace = ns::ATTENTION, name = "attention")]
+pub struct Attention;
impl MessagePayload for Attention {}
diff --git a/parsers/src/blocking.rs b/parsers/src/blocking.rs
index ecf3846..f0391b0 100644
--- a/parsers/src/blocking.rs
+++ b/parsers/src/blocking.rs
@@ -4,19 +4,19 @@
// 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/.
+use xso::{FromXml, IntoXml};
+
use crate::iq::{IqGetPayload, IqResultPayload, IqSetPayload};
use crate::ns;
use crate::Element;
use jid::Jid;
use xso::error::FromElementError;
-generate_empty_element!(
- /// The element requesting the blocklist, the result iq will contain a
- /// [BlocklistResult].
- BlocklistRequest,
- "blocklist",
- BLOCKING
-);
+/// The element requesting the blocklist, the result iq will contain a
+/// [BlocklistResult].
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::BLOCKING, name = "blocklist")]
+pub struct BlocklistRequest;
impl IqGetPayload for BlocklistRequest {}
@@ -87,12 +87,10 @@ generate_blocking_element!(
impl IqSetPayload for Unblock {}
-generate_empty_element!(
- /// The application-specific error condition when a message is blocked.
- Blocked,
- "blocked",
- BLOCKING_ERRORS
-);
+/// The application-specific error condition when a message is blocked.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::BLOCKING_ERRORS, name = "blocked")]
+pub struct Blocked;
#[cfg(test)]
mod tests {
diff --git a/parsers/src/carbons.rs b/parsers/src/carbons.rs
index 9b931ca..a3e5a3f 100644
--- a/parsers/src/carbons.rs
+++ b/parsers/src/carbons.rs
@@ -4,35 +4,32 @@
// 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/.
+use xso::{FromXml, IntoXml};
+
use crate::forwarding::Forwarded;
use crate::iq::IqSetPayload;
use crate::message::MessagePayload;
+use crate::ns;
-generate_empty_element!(
- /// Enable carbons for this session.
- Enable,
- "enable",
- CARBONS
-);
+/// Enable carbons for this session.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::CARBONS, name = "enable")]
+pub struct Enable;
impl IqSetPayload for Enable {}
-generate_empty_element!(
- /// Disable a previously-enabled carbons.
- Disable,
- "disable",
- CARBONS
-);
+/// Disable a previously-enabled carbons.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::CARBONS, name = "disable")]
+pub struct Disable;
impl IqSetPayload for Disable {}
-generate_empty_element!(
- /// Request the enclosing message to not be copied to other carbons-enabled
- /// resources of the user.
- Private,
- "private",
- CARBONS
-);
+/// Request the enclosing message to not be copied to other carbons-enabled
+/// resources of the user.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::CARBONS, name = "private")]
+pub struct Private;
impl MessagePayload for Private {}
diff --git a/parsers/src/cert_management.rs b/parsers/src/cert_management.rs
index 1e33dc1..5f8b1c8 100644
--- a/parsers/src/cert_management.rs
+++ b/parsers/src/cert_management.rs
@@ -4,7 +4,10 @@
// 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/.
+use xso::{FromXml, IntoXml};
+
use crate::iq::{IqGetPayload, IqResultPayload, IqSetPayload};
+use crate::ns;
use crate::util::text_node_codecs::{Base64, Codec};
generate_elem_id!(
@@ -40,12 +43,10 @@ generate_element!(
impl IqSetPayload for Append {}
-generate_empty_element!(
- /// Client requests the current list of X.509 certificates.
- ListCertsQuery,
- "items",
- SASL_CERT
-);
+/// Client requests the current list of X.509 certificates.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::SASL_CERT, name = "items")]
+pub struct ListCertsQuery;
impl IqGetPayload for ListCertsQuery {}
diff --git a/parsers/src/csi.rs b/parsers/src/csi.rs
index 3d26463..6693bd2 100644
--- a/parsers/src/csi.rs
+++ b/parsers/src/csi.rs
@@ -4,26 +4,24 @@
// 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_empty_element!(
- /// Stream:feature sent by the server to advertise it supports CSI.
- Feature,
- "csi",
- CSI
-);
+use xso::{FromXml, IntoXml};
-generate_empty_element!(
- /// Client indicates it is inactive.
- Inactive,
- "inactive",
- CSI
-);
+use crate::ns;
-generate_empty_element!(
- /// Client indicates it is active again.
- Active,
- "active",
- CSI
-);
+/// Stream:feature sent by the server to advertise it supports CSI.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::CSI, name = "csi")]
+pub struct Feature;
+
+/// Client indicates it is inactive.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::CSI, name = "inactive")]
+pub struct Inactive;
+
+/// Client indicates it is active again.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::CSI, name = "active")]
+pub struct Active;
#[cfg(test)]
mod tests {
diff --git a/parsers/src/jingle_rtp.rs b/parsers/src/jingle_rtp.rs
index ef3ae62..858dc28 100644
--- a/parsers/src/jingle_rtp.rs
+++ b/parsers/src/jingle_rtp.rs
@@ -4,17 +4,18 @@
// 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/.
+use xso::{FromXml, IntoXml};
+
use crate::jingle_rtcp_fb::RtcpFb;
use crate::jingle_rtp_hdrext::RtpHdrext;
use crate::jingle_ssma::{Group, Source};
+use crate::ns;
-generate_empty_element!(
- /// Specifies the ability to multiplex RTP Data and Control Packets on a single port as
- /// described in RFC 5761.
- RtcpMux,
- "rtcp-mux",
- JINGLE_RTP
-);
+/// Specifies the ability to multiplex RTP Data and Control Packets on a single port as
+/// described in RFC 5761.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::JINGLE_RTP, name = "rtcp-mux")]
+pub struct RtcpMux;
generate_element!(
/// Wrapper element describing an RTP session.
diff --git a/parsers/src/mix.rs b/parsers/src/mix.rs
index e6e30bb..adf92af 100644
--- a/parsers/src/mix.rs
+++ b/parsers/src/mix.rs
@@ -7,8 +7,11 @@
// TODO: validate nicks by applying the “nickname” profile of the PRECIS OpaqueString class, as
// defined in RFC 7700.
+use xso::{FromXml, IntoXml};
+
use crate::iq::{IqResultPayload, IqSetPayload};
use crate::message::MessagePayload;
+use crate::ns;
use crate::pubsub::{NodeName, PubSubPayload};
use jid::BareJid;
@@ -146,13 +149,11 @@ impl UpdateSubscription {
}
}
-generate_empty_element!(
- /// Request to leave a given MIX channel. It will automatically unsubscribe the user from all
- /// nodes on this channel.
- Leave,
- "leave",
- MIX_CORE
-);
+/// Request to leave a given MIX channel. It will automatically unsubscribe the user from all
+/// nodes on this channel.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::MIX_CORE, name = "leave")]
+pub struct Leave;
impl IqSetPayload for Leave {}
impl IqResultPayload for Leave {}
diff --git a/parsers/src/ping.rs b/parsers/src/ping.rs
index 8881c19..61c7ab8 100644
--- a/parsers/src/ping.rs
+++ b/parsers/src/ping.rs
@@ -5,15 +5,16 @@
// 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/.
-use crate::iq::IqGetPayload;
+use xso::{FromXml, IntoXml};
-generate_empty_element!(
- /// Represents a ping to the recipient, which must be answered with an
- /// empty `` or with an error.
- Ping,
- "ping",
- PING
-);
+use crate::iq::IqGetPayload;
+use crate::ns;
+
+/// Represents a ping to the recipient, which must be answered with an
+/// empty `` or with an error.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::PING, name = "ping")]
+pub struct Ping;
impl IqGetPayload for Ping {}
diff --git a/parsers/src/receipts.rs b/parsers/src/receipts.rs
index 28ce036..4b21a4d 100644
--- a/parsers/src/receipts.rs
+++ b/parsers/src/receipts.rs
@@ -4,15 +4,16 @@
// 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/.
-use crate::message::MessagePayload;
+use xso::{FromXml, IntoXml};
-generate_empty_element!(
- /// Requests that this message is acked by the final recipient once
- /// received.
- Request,
- "request",
- RECEIPTS
-);
+use crate::message::MessagePayload;
+use crate::ns;
+
+/// Requests that this message is acked by the final recipient once
+/// received.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::RECEIPTS, name = "request")]
+pub struct Request;
impl MessagePayload for Request {}
diff --git a/parsers/src/sasl.rs b/parsers/src/sasl.rs
index ace33a4..892a919 100644
--- a/parsers/src/sasl.rs
+++ b/parsers/src/sasl.rs
@@ -4,6 +4,8 @@
// 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/.
+use xso::{FromXml, IntoXml};
+
use crate::ns;
use crate::util::text_node_codecs::{Base64, Codec};
use crate::Element;
@@ -78,13 +80,11 @@ generate_element!(
)
);
-generate_empty_element!(
- /// Sent by the client at any point after [auth](struct.Auth.html) if it
- /// wants to cancel the current authentication process.
- Abort,
- "abort",
- SASL
-);
+/// Sent by the client at any point after [auth](struct.Auth.html) if it
+/// wants to cancel the current authentication process.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::SASL, name = "abort")]
+pub struct Abort;
generate_element!(
/// Sent by the server on SASL success.
diff --git a/parsers/src/sm.rs b/parsers/src/sm.rs
index cdf349e..e5483b7 100644
--- a/parsers/src/sm.rs
+++ b/parsers/src/sm.rs
@@ -4,6 +4,9 @@
// 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/.
+use xso::{FromXml, IntoXml};
+
+use crate::ns;
use crate::stanza_error::DefinedCondition;
generate_element!(
@@ -101,12 +104,10 @@ generate_element!(
]
);
-generate_empty_element!(
- /// Requests the currently received stanzas by the other party.
- R,
- "r",
- SM
-);
+/// Requests the currently received stanzas by the other party.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::SM, name = "r")]
+pub struct R;
generate_element!(
/// Requests a stream resumption.
@@ -135,12 +136,10 @@ generate_element!(
);
// TODO: add support for optional and required.
-generate_empty_element!(
- /// Represents availability of Stream Management in ``.
- StreamManagement,
- "sm",
- SM
-);
+/// Represents availability of Stream Management in ``.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::SM, name = "sm")]
+pub struct StreamManagement;
#[cfg(test)]
mod tests {
diff --git a/parsers/src/time.rs b/parsers/src/time.rs
index 7f10033..17041a4 100644
--- a/parsers/src/time.rs
+++ b/parsers/src/time.rs
@@ -4,6 +4,8 @@
// 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/.
+use xso::{FromXml, IntoXml};
+
use crate::date::DateTime;
use crate::iq::{IqGetPayload, IqResultPayload};
use crate::ns;
@@ -12,12 +14,10 @@ use chrono::FixedOffset;
use std::str::FromStr;
use xso::error::{Error, FromElementError};
-generate_empty_element!(
- /// An entity time query.
- TimeQuery,
- "time",
- TIME
-);
+/// An entity time query.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::TIME, name = "time")]
+pub struct TimeQuery;
impl IqGetPayload for TimeQuery {}
diff --git a/parsers/src/util/macros.rs b/parsers/src/util/macros.rs
index daa3570..0bc4f73 100644
--- a/parsers/src/util/macros.rs
+++ b/parsers/src/util/macros.rs
@@ -365,32 +365,6 @@ macro_rules! check_no_unknown_attributes {
);
}
-macro_rules! generate_empty_element {
- ($(#[$meta:meta])* $elem:ident, $name:tt, $ns:ident) => (
- $(#[$meta])*
- #[derive(Debug, Clone, PartialEq)]
- pub struct $elem;
-
- impl ::std::convert::TryFrom for $elem {
- type Error = xso::error::FromElementError;
-
- fn try_from(elem: crate::Element) -> Result<$elem, xso::error::FromElementError> {
- check_self!(elem, $name, $ns);
- check_no_children!(elem, $name);
- check_no_attributes!(elem, $name);
- Ok($elem)
- }
- }
-
- impl From<$elem> for crate::Element {
- fn from(_: $elem) -> crate::Element {
- crate::Element::builder($name, crate::ns::$ns)
- .build()
- }
- }
- );
-}
-
macro_rules! generate_id {
($(#[$meta:meta])* $elem:ident) => (
$(#[$meta])*
diff --git a/parsers/src/version.rs b/parsers/src/version.rs
index af417ab..98ff9b4 100644
--- a/parsers/src/version.rs
+++ b/parsers/src/version.rs
@@ -4,17 +4,18 @@
// 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/.
-use crate::iq::{IqGetPayload, IqResultPayload};
+use xso::{FromXml, IntoXml};
-generate_empty_element!(
- /// Represents a query for the software version a remote entity is using.
- ///
- /// It should only be used in an ``, as it can only
- /// represent the request, and not a result.
- VersionQuery,
- "query",
- VERSION
-);
+use crate::iq::{IqGetPayload, IqResultPayload};
+use crate::ns;
+
+/// Represents a query for the software version a remote entity is using.
+///
+/// It should only be used in an ``, as it can only
+/// represent the request, and not a result.
+#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
+#[xml(namespace = ns::VERSION, name = "query")]
+pub struct VersionQuery;
impl IqGetPayload for VersionQuery {}