From 3c7831027257b52ccf7b7cb6163e0d12cede8cfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= Date: Sat, 10 Aug 2024 12:19:14 +0200 Subject: [PATCH] parsers: add umbrella enum for SASL elements This is useful if, for example during stream negotiation, you want to parse SASL elements and nothing else. It is also useful if you want to write down an enum of all XMPP-related stream-level elements you accept and don't want to loose your fingers typing all the SASL options. --- parsers/src/sasl.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/parsers/src/sasl.rs b/parsers/src/sasl.rs index 588aa43d3d5937b759f9fe7caf7794506bcbc004..de4abb1bd0bdeddd7bf14a01c83f5d29f90690f6 100644 --- a/parsers/src/sasl.rs +++ b/parsers/src/sasl.rs @@ -163,6 +163,35 @@ pub struct Failure { pub texts: BTreeMap, } +/// Enum which allows parsing/serialising any SASL element. +#[derive(FromXml, AsXml, Debug, Clone)] +#[xml()] +pub enum Nonza { + /// Abortion of SASL transaction + #[xml(transparent)] + Abort(Abort), + + /// Failure of SASL transaction + #[xml(transparent)] + Failure(Failure), + + /// Success of SASL transaction + #[xml(transparent)] + Success(Success), + + /// Initiation of SASL transaction + #[xml(transparent)] + Auth(Auth), + + /// Challenge sent by the server to the client + #[xml(transparent)] + Challenge(Challenge), + + /// Response sent by the client to the server + #[xml(transparent)] + Response(Response), +} + #[cfg(test)] mod tests { use super::*;