Port crates to use new XSO-based xmlstream
This commit is contained in:
parent
7cfda820a6
commit
ab10e30ac0
26 changed files with 623 additions and 973 deletions
|
|
@ -127,6 +127,10 @@ impl<Io: AsyncBufRead + AsyncWrite> RawXmlStream<Io> {
|
|||
*this.parser.parser_pinned() = rxml::Parser::default();
|
||||
*this.writer = Self::new_writer(this.stream_ns);
|
||||
}
|
||||
|
||||
pub(super) fn into_inner(self) -> Io {
|
||||
self.parser.into_inner().0
|
||||
}
|
||||
}
|
||||
|
||||
impl<Io> RawXmlStream<Io> {
|
||||
|
|
|
|||
|
|
@ -83,4 +83,19 @@ impl<Io: AsyncBufRead + AsyncWrite + Unpin> PendingFeaturesRecv<Io> {
|
|||
let features = ReadXso::read_from(Pin::new(&mut stream)).await?;
|
||||
Ok((features, XmlStream::wrap(stream)))
|
||||
}
|
||||
|
||||
/// Skip receiving the responder's stream features.
|
||||
///
|
||||
/// The stream can be used for exchanging stream-level elements (stanzas
|
||||
/// or "nonzas"). The Rust type for these elements must be given as type
|
||||
/// parameter `T`.
|
||||
///
|
||||
/// **Note:** Using this on RFC 6120 compliant streams where stream
|
||||
/// features **are** sent after the stream header will cause a parse error
|
||||
/// down the road (because the feature stream element cannot be handled).
|
||||
/// The only place where this is useful is in
|
||||
/// [XEP-0114](https://xmpp.org/extensions/xep-0114.html) connections.
|
||||
pub fn skip_features<T: FromXml + AsXml>(self) -> XmlStream<Io, T> {
|
||||
XmlStream::wrap(self.stream)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ mod responder;
|
|||
mod tests;
|
||||
pub(crate) mod xmpp;
|
||||
|
||||
use self::common::{RawXmlStream, ReadXsoError, ReadXsoState, StreamHeader};
|
||||
pub use self::common::StreamHeader;
|
||||
use self::common::{RawXmlStream, ReadXsoError, ReadXsoState};
|
||||
pub use self::initiator::{InitiatingStream, PendingFeaturesRecv};
|
||||
pub use self::responder::{AcceptedStream, PendingFeaturesSend};
|
||||
pub use self::xmpp::XmppStreamElement;
|
||||
|
|
@ -235,6 +236,12 @@ impl<Io: AsyncBufRead + AsyncWrite + Unpin, T: FromXml + AsXml> XmlStream<Io, T>
|
|||
let header = StreamHeader::recv(Pin::new(&mut stream)).await?;
|
||||
Ok(AcceptedStream { stream, header })
|
||||
}
|
||||
|
||||
/// Discard all XML state and return the inner I/O object.
|
||||
pub fn into_inner(self) -> Io {
|
||||
self.assert_retypable();
|
||||
self.inner.into_inner()
|
||||
}
|
||||
}
|
||||
|
||||
impl<Io: AsyncBufRead, T: FromXml + AsXml> Stream for XmlStream<Io, T> {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use xmpp_parsers::{iq::Iq, message::Message, presence::Presence, sasl, starttls};
|
||||
use xmpp_parsers::{component, iq::Iq, message::Message, presence::Presence, sasl, starttls};
|
||||
|
||||
/// Any valid XMPP stream-level element.
|
||||
#[derive(FromXml, AsXml, Debug)]
|
||||
|
|
@ -31,4 +31,8 @@ pub enum XmppStreamElement {
|
|||
/// STARTTLS-related nonza
|
||||
#[xml(transparent)]
|
||||
Starttls(starttls::Nonza),
|
||||
|
||||
/// Component protocol nonzas
|
||||
#[xml(transparent)]
|
||||
ComponentHandshake(component::Handshake),
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue