xmpp-parsers/iq: Add a helper to create an empty result iq.

Emmanuel Gil Peyrot created

This can be useful to reply to a get/set iq.

Change summary

xmpp-parsers/src/iq.rs | 10 ++++++++++
1 file changed, 10 insertions(+)

Detailed changes

xmpp-parsers/src/iq.rs 🔗

@@ -90,6 +90,16 @@ impl Iq {
         }
     }
 
+    /// Creates an empty `<iq type="result"/>` stanza.
+    pub fn empty_result<S: Into<String>>(to: Jid, id: S) -> Iq {
+        Iq {
+            from: None,
+            to: Some(to),
+            id: id.into(),
+            payload: IqType::Result(None),
+        }
+    }
+
     /// Creates an `<iq/>` stanza containing a result.
     pub fn from_result<S: Into<String>>(id: S, payload: Option<impl IqResultPayload>) -> Iq {
         Iq {