xmlstream: introduce XMPP specifics
This commit is contained in:
parent
2c944ebbf8
commit
7cfda820a6
2 changed files with 39 additions and 0 deletions
|
|
@ -52,10 +52,12 @@ mod initiator;
|
||||||
mod responder;
|
mod responder;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
pub(crate) mod xmpp;
|
||||||
|
|
||||||
use self::common::{RawXmlStream, ReadXsoError, ReadXsoState, StreamHeader};
|
use self::common::{RawXmlStream, ReadXsoError, ReadXsoState, StreamHeader};
|
||||||
pub use self::initiator::{InitiatingStream, PendingFeaturesRecv};
|
pub use self::initiator::{InitiatingStream, PendingFeaturesRecv};
|
||||||
pub use self::responder::{AcceptedStream, PendingFeaturesSend};
|
pub use self::responder::{AcceptedStream, PendingFeaturesSend};
|
||||||
|
pub use self::xmpp::XmppStreamElement;
|
||||||
|
|
||||||
/// Initiate a new stream
|
/// Initiate a new stream
|
||||||
///
|
///
|
||||||
|
|
@ -321,3 +323,6 @@ impl<'x, Io: AsyncWrite, T: FromXml + AsXml> Sink<&'x T> for XmlStream<Io, T> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convenience alias for an XML stream using [`XmppStreamElement`].
|
||||||
|
pub type XmppStream<Io> = XmlStream<Io, XmppStreamElement>;
|
||||||
|
|
|
||||||
34
tokio-xmpp/src/xmlstream/xmpp.rs
Normal file
34
tokio-xmpp/src/xmlstream/xmpp.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
// Copyright (c) 2024 Jonas Schäfer <jonas@zombofant.net>
|
||||||
|
//
|
||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
use xso::{AsXml, FromXml};
|
||||||
|
|
||||||
|
use xmpp_parsers::{iq::Iq, message::Message, presence::Presence, sasl, starttls};
|
||||||
|
|
||||||
|
/// Any valid XMPP stream-level element.
|
||||||
|
#[derive(FromXml, AsXml, Debug)]
|
||||||
|
#[xml()]
|
||||||
|
pub enum XmppStreamElement {
|
||||||
|
/// IQ stanza
|
||||||
|
#[xml(transparent)]
|
||||||
|
Iq(Iq),
|
||||||
|
|
||||||
|
/// Message stanza
|
||||||
|
#[xml(transparent)]
|
||||||
|
Message(Message),
|
||||||
|
|
||||||
|
/// Presence stanza
|
||||||
|
#[xml(transparent)]
|
||||||
|
Presence(Presence),
|
||||||
|
|
||||||
|
/// SASL-related nonza
|
||||||
|
#[xml(transparent)]
|
||||||
|
Sasl(sasl::Nonza),
|
||||||
|
|
||||||
|
/// STARTTLS-related nonza
|
||||||
|
#[xml(transparent)]
|
||||||
|
Starttls(starttls::Nonza),
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue