From 1a7dec6f1e1d6445ce77859c07567aae874900e7 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 24 Jul 2024 18:07:06 +0200 Subject: [PATCH] =?UTF-8?q?xmpp-parsers:=20Convert=20sm=E2=80=99s=20Enable?= =?UTF-8?q?=20and=20Enabled=20to=20xso?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parsers/src/sm.rs | 59 +++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/parsers/src/sm.rs b/parsers/src/sm.rs index 3142d5fc..c22ee03f 100644 --- a/parsers/src/sm.rs +++ b/parsers/src/sm.rs @@ -32,19 +32,19 @@ generate_attribute!( bool ); -generate_element!( - /// Client request for enabling stream management. - #[derive(Default)] - Enable, "enable", SM, - attributes: [ - /// The preferred resumption time in seconds by the client. - // TODO: should be the infinite integer set ≥ 1. - max: Option = "max", +/// Client request for enabling stream management. +#[derive(FromXml, AsXml, PartialEq, Debug, Clone, Default)] +#[xml(namespace = ns::SM, name = "enable")] +pub struct Enable { + /// The preferred resumption time in seconds by the client. + // TODO: should be the infinite integer set ≥ 1. + #[xml(attribute(default))] + pub max: Option, - /// Whether the client wants to be allowed to resume the stream. - resume: Default = "resume", - ] -); + /// Whether the client wants to be allowed to resume the stream. + #[xml(attribute(default))] + pub resume: ResumeAttr, +} impl Enable { /// Generates a new `` element. @@ -70,25 +70,28 @@ generate_id!( StreamId ); -generate_element!( - /// Server response once stream management is enabled. - Enabled, "enabled", SM, - attributes: [ - /// A random identifier used for stream resumption. - id: Option = "id", +/// Server response once stream management is enabled. +#[derive(FromXml, AsXml, PartialEq, Debug, Clone)] +#[xml(namespace = ns::SM, name = "enabled")] +pub struct Enabled { + /// A random identifier used for stream resumption. + #[xml(attribute(default))] + pub id: Option, - /// The preferred IP, domain, IP:port or domain:port location for - /// resumption. - location: Option = "location", + /// The preferred IP, domain, IP:port or domain:port location for + /// resumption. + #[xml(attribute(default))] + pub location: Option, - /// The preferred resumption time in seconds by the server. - // TODO: should be the infinite integer set ≥ 1. - max: Option = "max", + /// The preferred resumption time in seconds by the server. + // TODO: should be the infinite integer set ≥ 1. + #[xml(attribute(default))] + pub max: Option, - /// Whether stream resumption is allowed. - resume: Default = "resume", - ] -); + /// Whether stream resumption is allowed. + #[xml(attribute(default))] + pub resume: ResumeAttr, +} generate_element!( /// A stream management error happened.