From 4d6e1363db343c425339a00d353e4747cc8eda00 Mon Sep 17 00:00:00 2001 From: Link Mauve Date: Sun, 25 Jan 2026 18:12:46 +0100 Subject: [PATCH] xmpp-parsers: Replace bind::Required with an #[xml(flag)] This makes the code simpler to read. --- parsers/ChangeLog | 1 + parsers/src/bind.rs | 11 ++--------- parsers/src/starttls.rs | 1 + 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/parsers/ChangeLog b/parsers/ChangeLog index c928714e..0aa4821a 100644 --- a/parsers/ChangeLog +++ b/parsers/ChangeLog @@ -11,6 +11,7 @@ XXXX-YY-ZZ RELEASER used in XMPP. - Remove the unnecessary SaslMechanisms struct, to directly extract SASL mechanisms in a Vec in StreamFeatures. + - bind::BindFeature::required is now a bool, thanks to xso’s flag. * Improvements: - Make Priority’s inner i8 pub, which had been broken since the conversion to xso. (!632) diff --git a/parsers/src/bind.rs b/parsers/src/bind.rs index 4ea5e4fa..47826e21 100644 --- a/parsers/src/bind.rs +++ b/parsers/src/bind.rs @@ -15,15 +15,10 @@ use jid::{FullJid, Jid}; #[xml(namespace = ns::BIND, name = "bind")] pub struct BindFeature { /// Present if bind is required. - #[xml(child(default))] - required: Option, + #[xml(flag)] + required: bool, } -/// 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. /// @@ -84,7 +79,6 @@ mod tests { #[test] fn test_size() { assert_size!(BindFeature, 1); - assert_size!(Required, 0); assert_size!(BindQuery, 12); assert_size!(BindResponse, 16); } @@ -93,7 +87,6 @@ mod tests { #[test] fn test_size() { assert_size!(BindFeature, 1); - assert_size!(Required, 0); assert_size!(BindQuery, 24); assert_size!(BindResponse, 32); } diff --git a/parsers/src/starttls.rs b/parsers/src/starttls.rs index 1cc7eac7..4f52d005 100644 --- a/parsers/src/starttls.rs +++ b/parsers/src/starttls.rs @@ -60,6 +60,7 @@ mod tests { fn test_size() { assert_size!(Request, 0); assert_size!(Proceed, 0); + assert_size!(Failure, 0); assert_size!(StartTls, 1); assert_size!(Nonza, 1); }