@@ -10,6 +10,20 @@ use crate::iq::{IqResultPayload, IqSetPayload};
use crate::ns;
use jid::{FullJid, Jid};
+/// The bind feature exposed in stream:features.
+#[derive(FromXml, AsXml, Debug, Clone, PartialEq)]
+#[xml(namespace = ns::BIND, name = "bind")]
+pub struct BindFeature {
+ /// Present if bind is required.
+ #[xml(child(default))]
+ required: Option<Required>,
+}
+
+/// Notes that bind is required.
+#[derive(FromXml, AsXml, Debug, Clone, PartialEq)]
+#[xml(namespace = ns::BIND, name = "required")]
+pub struct Required;
+
/// The request for resource binding, which is the process by which a client
/// can obtain a full JID and start exchanging on the XMPP network.
///
@@ -68,6 +82,8 @@ mod tests {
#[cfg(target_pointer_width = "32")]
#[test]
fn test_size() {
+ assert_size!(BindFeature, 1);
+ assert_size!(Required, 0);
assert_size!(BindQuery, 12);
assert_size!(BindResponse, 16);
}
@@ -75,6 +91,8 @@ mod tests {
#[cfg(target_pointer_width = "64")]
#[test]
fn test_size() {
+ assert_size!(BindFeature, 1);
+ assert_size!(Required, 0);
assert_size!(BindQuery, 24);
assert_size!(BindResponse, 32);
}
@@ -7,6 +7,7 @@
use minidom::Element;
use xso::{AsXml, FromXml};
+use crate::bind::BindFeature;
use crate::ns;
/// Wraps `<stream:features/>`, usually the very first nonza of a
@@ -20,7 +21,7 @@ pub struct StreamFeatures {
/// Bind is supported.
#[xml(child(default))]
- pub bind: Option<Bind>,
+ pub bind: Option<BindFeature>,
/// List of supported SASL mechanisms
#[xml(child(default))]
@@ -48,11 +49,6 @@ pub struct StartTls {
#[xml(namespace = ns::TLS, name = "required")]
pub struct RequiredStartTls;
-/// Bind is supported.
-#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
-#[xml(namespace = ns::BIND, name = "bind")]
-pub struct Bind;
-
/// List of supported SASL mechanisms
#[derive(FromXml, AsXml, PartialEq, Debug, Clone, Default)]
#[xml(namespace = ns::SASL, name = "mechanisms")]
@@ -93,7 +89,6 @@ mod tests {
fn test_size() {
assert_size!(SaslMechanism, 12);
assert_size!(SaslMechanisms, 12);
- assert_size!(Bind, 0);
assert_size!(RequiredStartTls, 0);
assert_size!(StartTls, 1);
assert_size!(StreamFeatures, 28);
@@ -104,7 +99,6 @@ mod tests {
fn test_size() {
assert_size!(SaslMechanism, 24);
assert_size!(SaslMechanisms, 24);
- assert_size!(Bind, 0);
assert_size!(RequiredStartTls, 0);
assert_size!(StartTls, 1);
assert_size!(StreamFeatures, 56);