xmpp.rs

 1// Copyright (c) 2024 Jonas Schäfer <jonas@zombofant.net>
 2//
 3// This Source Code Form is subject to the terms of the Mozilla Public
 4// License, v. 2.0. If a copy of the MPL was not distributed with this
 5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
 6
 7use xso::{AsXml, FromXml};
 8
 9use xmpp_parsers::{component, sasl, sm, starttls, stream_error::ReceivedStreamError};
10
11use crate::Stanza;
12
13/// Any valid XMPP stream-level element.
14#[derive(FromXml, AsXml, Debug)]
15#[xml()]
16pub enum XmppStreamElement {
17    /// Stanza
18    #[xml(transparent)]
19    Stanza(Stanza),
20
21    /// SASL-related nonza
22    #[xml(transparent)]
23    Sasl(sasl::Nonza),
24
25    /// STARTTLS-related nonza
26    #[xml(transparent)]
27    Starttls(starttls::Nonza),
28
29    /// Component protocol nonzas
30    #[xml(transparent)]
31    ComponentHandshake(component::Handshake),
32
33    /// Stream error received
34    #[xml(transparent)]
35    StreamError(ReceivedStreamError),
36
37    /// XEP-0198 nonzas
38    #[xml(transparent)]
39    SM(sm::Nonza),
40}