From 9e9186ef7b3ff25e76609d6beff468a2a7631812 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 4 Aug 2024 16:56:22 +0200 Subject: [PATCH] xmpp-parsers: Convert MUC to xso --- parsers/src/muc/muc.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/parsers/src/muc/muc.rs b/parsers/src/muc/muc.rs index ba5b2060..c9aa0b08 100644 --- a/parsers/src/muc/muc.rs +++ b/parsers/src/muc/muc.rs @@ -63,17 +63,18 @@ impl History { } } -generate_element!( - /// Represents a room join request. - #[derive(Default)] - Muc, "x", MUC, children: [ - /// Password to use when the room is protected by a password. - password: Option = ("password", MUC) => String, +/// Represents a room join request. +#[derive(FromXml, AsXml, PartialEq, Debug, Clone, Default)] +#[xml(namespace = ns::MUC, name = "x")] +pub struct Muc { + /// Password to use when the room is protected by a password. + #[xml(extract(default, fields(text(type_ = String))))] + pub password: Option, - /// Controls how much and how old we want to receive history on join. - history: Option = ("history", MUC) => History - ] -); + /// Controls how much and how old we want to receive history on join. + #[xml(child(default))] + pub history: Option, +} impl PresencePayload for Muc {} @@ -121,7 +122,7 @@ mod tests { FromElementError::Invalid(Error::Other(string)) => string, _ => panic!(), }; - assert_eq!(message, "Unknown child in x element."); + assert_eq!(message, "Unknown child in Muc element."); } #[test] @@ -148,7 +149,7 @@ mod tests { FromElementError::Invalid(Error::Other(string)) => string, _ => panic!(), }; - assert_eq!(message, "Unknown attribute in x element."); + assert_eq!(message, "Unknown attribute in Muc element."); } #[test]