From 726801610fad2ae6bcdaae6ddbab6ed47fac576e Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 24 Jul 2024 18:12:55 +0200 Subject: [PATCH] xmpp-parsers: Convert ibb to xso --- parsers/src/ibb.rs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/parsers/src/ibb.rs b/parsers/src/ibb.rs index ea74ec23..29ca9364 100644 --- a/parsers/src/ibb.rs +++ b/parsers/src/ibb.rs @@ -27,19 +27,22 @@ Stanza, "stanza", { Message => "message", }, Default = Iq); -generate_element!( /// Starts an In-Band Bytestream session with the given parameters. -Open, "open", IBB, -attributes: [ +#[derive(FromXml, AsXml, PartialEq, Debug, Clone)] +#[xml(namespace = ns::IBB, name = "open")] +pub struct Open { /// Maximum size in bytes for each chunk. - block_size: Required = "block-size", + #[xml(attribute(name = "block-size"))] + pub block_size: u16, /// The identifier to be used to create a stream. - sid: Required = "sid", + #[xml(attribute)] + pub sid: StreamId, /// Which stanza type to use to exchange data. - stanza: Default = "stanza", -]); + #[xml(attribute(default))] + pub stanza: Stanza, +} impl IqSetPayload for Open {} @@ -138,7 +141,10 @@ mod tests { FromElementError::Invalid(Error::Other(string)) => string, _ => panic!(), }; - assert_eq!(message, "Required attribute 'block-size' missing."); + assert_eq!( + message, + "Required attribute field 'block_size' on Open element missing." + ); let elem: Element = "" .parse() @@ -162,7 +168,10 @@ mod tests { FromElementError::Invalid(Error::Other(error)) => error, _ => panic!(), }; - assert_eq!(message, "Required attribute 'sid' missing."); + assert_eq!( + message, + "Required attribute field 'sid' on Open element missing." + ); } #[test]