From f466b1862232cd2b1ff964fdf9ab0f858b95f08b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= Date: Sun, 4 Aug 2024 15:12:25 +0200 Subject: [PATCH] parsers: port version to derive macros We can *finally* do it! --- parsers/src/version.rs | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/parsers/src/version.rs b/parsers/src/version.rs index 3a903a88..7184528c 100644 --- a/parsers/src/version.rs +++ b/parsers/src/version.rs @@ -19,23 +19,25 @@ pub struct VersionQuery; impl IqGetPayload for VersionQuery {} -generate_element!( - /// Represents the answer about the software version we are using. - /// - /// It should only be used in an ``, as it can only - /// represent the result, and not a request. - VersionResult, "query", VERSION, - children: [ - /// The name of this client. - name: Required = ("name", VERSION) => String, +/// Represents the answer about the software version we are using. +/// +/// It should only be used in an ``, as it can only +/// represent the result, and not a request. +#[derive(FromXml, AsXml, PartialEq, Debug, Clone)] +#[xml(namespace = ns::VERSION, name = "query")] +pub struct VersionResult { + /// The name of this client. + #[xml(extract(fields(text)))] + pub name: String, - /// The version of this client. - version: Required = ("version", VERSION) => String, + /// The version of this client. + #[xml(extract(fields(text)))] + pub version: String, - /// The OS this client is running on. - os: Option = ("os", VERSION) => String - ] -); + /// The OS this client is running on. + #[xml(extract(default, fields(text(type_ = String))))] + pub os: Option, +} impl IqResultPayload for VersionResult {}