diff --git a/src/bind.rs b/src/bind.rs index 45976361..97a75aa3 100644 --- a/src/bind.rs +++ b/src/bind.rs @@ -12,6 +12,7 @@ use minidom::Element; use error::Error; use jid::Jid; use ns; +use iq::{IqSetPayload, IqResultPayload}; #[derive(Debug, Clone, PartialEq)] pub enum Bind { @@ -29,6 +30,9 @@ impl Bind { } } +impl IqSetPayload for Bind {} +impl IqResultPayload for Bind {} + impl TryFrom for Bind { type Err = Error; diff --git a/src/blocking.rs b/src/blocking.rs index b24c9e49..11287ba7 100644 --- a/src/blocking.rs +++ b/src/blocking.rs @@ -12,9 +12,12 @@ use minidom::Element; use error::Error; use ns; +use iq::{IqGetPayload, IqSetPayload, IqResultPayload}; generate_empty_element!(BlocklistRequest, "blocklist", BLOCKING); +impl IqGetPayload for BlocklistRequest {} + macro_rules! generate_blocking_element { ($elem:ident, $name:tt) => ( #[derive(Debug, Clone)] @@ -59,6 +62,10 @@ generate_blocking_element!(BlocklistResult, "blocklist"); generate_blocking_element!(Block, "block"); generate_blocking_element!(Unblock, "unblock"); +impl IqResultPayload for BlocklistResult {} +impl IqSetPayload for Block {} +impl IqSetPayload for Unblock {} + generate_empty_element!(Blocked, "blocked", BLOCKING_ERRORS); #[cfg(test)] diff --git a/src/disco.rs b/src/disco.rs index 136a50ad..ea49476c 100644 --- a/src/disco.rs +++ b/src/disco.rs @@ -14,6 +14,7 @@ use jid::Jid; use error::Error; use ns; +use iq::{IqGetPayload, IqResultPayload}; use data_forms::{DataForm, DataFormType}; generate_element_with_only_attributes!( @@ -26,6 +27,8 @@ DiscoInfoQuery, "query", DISCO_INFO, [ node: Option = "node" => optional, ]); +impl IqGetPayload for DiscoItemsQuery {} + generate_element_with_only_attributes!( /// Structure representing a `` element. #[derive(PartialEq)] @@ -108,6 +111,8 @@ pub struct DiscoInfoResult { pub extensions: Vec, } +impl IqResultPayload for DiscoInfoResult {} + impl TryFrom for DiscoInfoResult { type Err = Error; @@ -190,6 +195,8 @@ DiscoItemsQuery, "query", DISCO_ITEMS, [ node: Option = "node" => optional, ]); +impl IqGetPayload for DiscoInfoResult {} + generate_element_with_only_attributes!( /// Structure representing an `` element. Item, "item", DISCO_ITEMS, [ @@ -218,6 +225,8 @@ generate_element_with_children!( ] ); +impl IqResultPayload for DiscoItemsResult {} + #[cfg(test)] mod tests { use super::*; diff --git a/src/ibb.rs b/src/ibb.rs index 9c2cdccc..e33ca3bf 100644 --- a/src/ibb.rs +++ b/src/ibb.rs @@ -5,6 +5,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. use helpers::Base64; +use iq::IqSetPayload; generate_attribute!(Stanza, "stanza", { Iq => "iq", @@ -17,6 +18,8 @@ generate_element_with_only_attributes!(Open, "open", IBB, [ stanza: Stanza = "stanza" => default, ]); +impl IqSetPayload for Open {} + generate_element_with_text!(Data, "data", IBB, [ seq: u16 = "seq" => required, @@ -25,10 +28,14 @@ generate_element_with_text!(Data, "data", IBB, data: Base64> ); +impl IqSetPayload for Data {} + generate_element_with_only_attributes!(Close, "close", IBB, [ sid: String = "sid" => required, ]); +impl IqSetPayload for Close {} + #[cfg(test)] mod tests { use super::*; diff --git a/src/ibr.rs b/src/ibr.rs index 99cbcd57..72c02b2b 100644 --- a/src/ibr.rs +++ b/src/ibr.rs @@ -11,6 +11,7 @@ use minidom::Element; use error::Error; +use iq::{IqGetPayload, IqSetPayload, IqResultPayload}; use data_forms::DataForm; use ns; @@ -25,6 +26,10 @@ pub struct Query { //pub oob: Option, } +impl IqGetPayload for Query; +impl IqSetPayload for Query; +impl IqResultPayload for Query; + impl TryFrom for Query { type Err = Error; diff --git a/src/jingle.rs b/src/jingle.rs index 8d7d309e..b64b0e7c 100644 --- a/src/jingle.rs +++ b/src/jingle.rs @@ -12,6 +12,7 @@ use jid::Jid; use error::Error; use ns; +use iq::IqSetPayload; generate_attribute!(Action, "action", { ContentAccept => "content-accept", @@ -305,6 +306,8 @@ pub struct Jingle { pub other: Vec, } +impl IqSetPayload for Jingle {} + impl Jingle { pub fn new(action: Action, sid: SessionId) -> Jingle { Jingle { diff --git a/src/mam.rs b/src/mam.rs index 22052cf3..664947ee 100644 --- a/src/mam.rs +++ b/src/mam.rs @@ -11,6 +11,7 @@ use jid::Jid; use error::Error; +use iq::{IqGetPayload, IqSetPayload, IqResultPayload}; use data_forms::DataForm; use rsm::Set; use forwarding::Forwarded; @@ -25,6 +26,10 @@ pub struct Query { pub set: Option, } +impl IqGetPayload for Query {} +impl IqSetPayload for Query {} +impl IqResultPayload for Query {} + generate_element_with_children!( Result_, "result", MAM, attributes: [ @@ -42,6 +47,8 @@ pub struct Fin { pub set: Set, } +impl IqResultPayload for Fin {} + generate_attribute!(DefaultPrefs, "default", { Always => "always", Never => "never", @@ -55,6 +62,10 @@ pub struct Prefs { pub never: Vec, } +impl IqGetPayload for Prefs {} +impl IqSetPayload for Prefs {} +impl IqResultPayload for Prefs {} + impl TryFrom for Query { type Err = Error; diff --git a/src/ping.rs b/src/ping.rs index 8159ffe9..c2f0a440 100644 --- a/src/ping.rs +++ b/src/ping.rs @@ -5,8 +5,12 @@ // 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 iq::IqGetPayload; + generate_empty_element!(Ping, "ping", PING); +impl IqGetPayload for Ping {} + #[cfg(test)] mod tests { use super::*; diff --git a/src/pubsub/pubsub.rs b/src/pubsub/pubsub.rs index d90ca982..569a954a 100644 --- a/src/pubsub/pubsub.rs +++ b/src/pubsub/pubsub.rs @@ -15,6 +15,7 @@ use error::Error; use ns; +use iq::{IqGetPayload, IqSetPayload, IqResultPayload}; use data_forms::DataForm; use pubsub::{NodeName, ItemId, Subscription, SubscriptionId}; @@ -364,6 +365,10 @@ pub enum PubSub { Unsubscribe(Unsubscribe), } +impl IqGetPayload for PubSub {} +impl IqSetPayload for PubSub {} +impl IqResultPayload for PubSub {} + impl TryFrom for PubSub { type Err = Error; diff --git a/src/roster.rs b/src/roster.rs index 2b62f808..e851c485 100644 --- a/src/roster.rs +++ b/src/roster.rs @@ -5,6 +5,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. use jid::Jid; +use iq::{IqGetPayload, IqSetPayload, IqResultPayload}; generate_elem_id!(Group, "group", ROSTER); @@ -54,6 +55,10 @@ generate_element_with_children!( ] ); +impl IqGetPayload for Roster {} +impl IqSetPayload for Roster {} +impl IqResultPayload for Roster {} + #[cfg(test)] mod tests { use super::*; diff --git a/src/version.rs b/src/version.rs index e01a40d3..49b23ad9 100644 --- a/src/version.rs +++ b/src/version.rs @@ -8,6 +8,7 @@ use try_from::TryFrom; use minidom::Element; use error::Error; use ns; +use iq::{IqGetPayload, IqResultPayload}; #[derive(Debug, Clone)] pub struct Version { @@ -16,6 +17,9 @@ pub struct Version { pub os: Option, } +impl IqGetPayload for Version {} +impl IqResultPayload for Version {} + impl TryFrom for Version { type Err = Error;