tokio-xmpp: use xmpp_parsers::ns everywhere
This commit is contained in:
parent
1a06a09774
commit
e501addb96
9 changed files with 23 additions and 41 deletions
|
|
@ -1,9 +1,7 @@
|
|||
//! Contains wrapper for `<stream:features/>`
|
||||
|
||||
use crate::client::{NS_XMPP_BIND, NS_XMPP_SASL};
|
||||
use crate::error::AuthError;
|
||||
use crate::starttls::NS_XMPP_TLS;
|
||||
use xmpp_parsers::Element;
|
||||
use xmpp_parsers::{ns, Element};
|
||||
|
||||
/// Wraps `<stream:features/>`, usually the very first nonza of an
|
||||
/// XMPPStream.
|
||||
|
|
@ -20,22 +18,22 @@ impl StreamFeatures {
|
|||
|
||||
/// Can initiate TLS session with this server?
|
||||
pub fn can_starttls(&self) -> bool {
|
||||
self.0.get_child("starttls", NS_XMPP_TLS).is_some()
|
||||
self.0.get_child("starttls", ns::TLS).is_some()
|
||||
}
|
||||
|
||||
/// Iterate over SASL mechanisms
|
||||
pub fn sasl_mechanisms<'a>(&'a self) -> Result<impl Iterator<Item = String> + 'a, AuthError> {
|
||||
Ok(self
|
||||
.0
|
||||
.get_child("mechanisms", NS_XMPP_SASL)
|
||||
.get_child("mechanisms", ns::SASL)
|
||||
.ok_or(AuthError::NoMechanism)?
|
||||
.children()
|
||||
.filter(|child| child.is("mechanism", NS_XMPP_SASL))
|
||||
.filter(|child| child.is("mechanism", ns::SASL))
|
||||
.map(|mech_el| mech_el.text()))
|
||||
}
|
||||
|
||||
/// Does server support user resource binding?
|
||||
pub fn can_bind(&self) -> bool {
|
||||
self.0.get_child("bind", NS_XMPP_BIND).is_some()
|
||||
self.0.get_child("bind", ns::BIND).is_some()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue