xmpp-parsers: Replace bind::Required with an #[xml(flag)]

This makes the code simpler to read.
This commit is contained in:
Link Mauve 2026-01-25 18:12:46 +01:00 committed by Jonas Schäfer
commit 4d6e1363db
3 changed files with 4 additions and 9 deletions

View file

@ -11,6 +11,7 @@ XXXX-YY-ZZ RELEASER <admin@example.com>
used in XMPP.
- Remove the unnecessary SaslMechanisms struct, to directly extract
SASL mechanisms in a Vec<String> in StreamFeatures.
- bind::BindFeature::required is now a bool, thanks to xsos flag.
* Improvements:
- Make Prioritys inner i8 pub, which had been broken since the
conversion to xso. (!632)

View file

@ -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<Required>,
#[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);
}

View file

@ -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);
}