tokio-xmpp: add StreamFeatures to Online event

This commit is contained in:
famfo 2026-01-05 22:37:13 +01:00 committed by pep
commit d84cb261e4
3 changed files with 9 additions and 1 deletions

View file

@ -5,6 +5,9 @@ Version NEXT:
new default. The newly-introduced `pedantic` feature can be used to new default. The newly-introduced `pedantic` feature can be used to
opt into the previous default behaviour of rejecting all unknown opt into the previous default behaviour of rejecting all unknown
child elements and attributes. child elements and attributes.
* Breaking:
- Add `xmpp_parsers::stream_features::StreamFeatures` to
`tokio_xmpp::event::Online` (!631)
* Added: * Added:
- Expose `client_auth` method to allow manual stream setups for advanced - Expose `client_auth` method to allow manual stream setups for advanced
use cases. use cases.

View file

@ -46,7 +46,7 @@ impl Stream for Client {
bound_jid, bound_jid,
features, features,
})) => { })) => {
self.features = Some(features); self.features = Some(features.clone());
self.bound_jid = Some(bound_jid.clone()); self.bound_jid = Some(bound_jid.clone());
self.iq_response_tracker self.iq_response_tracker
@ -54,11 +54,13 @@ impl Stream for Client {
Some(Event::Online { Some(Event::Online {
bound_jid, bound_jid,
features,
resumed: false, resumed: false,
}) })
} }
Some(StanzaStreamEvent::Stream(StreamEvent::Resumed)) => Some(Event::Online { Some(StanzaStreamEvent::Stream(StreamEvent::Resumed)) => Some(Event::Online {
bound_jid: self.bound_jid.as_ref().unwrap().clone(), bound_jid: self.bound_jid.as_ref().unwrap().clone(),
features: self.features.as_ref().unwrap().clone(),
resumed: true, resumed: true,
}), }),
Some(StanzaStreamEvent::Stream(StreamEvent::Suspended)) => continue, Some(StanzaStreamEvent::Stream(StreamEvent::Suspended)) => continue,

View file

@ -9,6 +9,7 @@ use xmpp_parsers::{
jid::Jid, jid::Jid,
message::{Id, Message}, message::{Id, Message},
presence::Presence, presence::Presence,
stream_features::StreamFeatures,
}; };
use xso::{AsXml, FromXml}; use xso::{AsXml, FromXml};
@ -125,6 +126,8 @@ pub enum Event {
/// expected, so use this one instead of the JID with which /// expected, so use this one instead of the JID with which
/// the connection was setup. /// the connection was setup.
bound_jid: Jid, bound_jid: Jid,
/// Features supported by the server
features: StreamFeatures,
/// Was this session resumed? /// Was this session resumed?
/// ///
/// Not yet implemented for the Client /// Not yet implemented for the Client