use Stream 'ns' value

This commit is contained in:
cel 🌸 2023-07-12 13:03:04 +01:00
parent 39b7d3cb63
commit 84d861c2b2
Signed by: cel
GPG Key ID: 48E29AF13B5F1349
2 changed files with 7 additions and 5 deletions

View File

@ -52,7 +52,6 @@ impl<'j> JabberClient<'j> {
pub async fn get_features(&mut self) -> Result<Option<Vec<StreamFeature>>> { pub async fn get_features(&mut self) -> Result<Option<Vec<StreamFeature>>> {
if let Some(features) = Element::read(&mut self.reader).await? { if let Some(features) = Element::read(&mut self.reader).await? {
println!("{:?}", features);
Ok(Some(features.try_into()?)) Ok(Some(features.try_into()?))
} else { } else {
Ok(None) Ok(None)

View File

@ -43,7 +43,7 @@ pub struct Stream {
to: Option<JID>, to: Option<JID>,
version: Option<String>, version: Option<String>,
lang: Option<String>, lang: Option<String>,
_ns: XMLNS, ns: XMLNS,
} }
impl Stream { impl Stream {
@ -54,7 +54,7 @@ impl Stream {
to: Some(to.clone()), to: Some(to.clone()),
version: Some(VERSION.to_owned()), version: Some(VERSION.to_owned()),
lang, lang,
_ns: XMLNS::Client, ns: XMLNS::Client,
} }
} }
@ -75,7 +75,10 @@ impl Stream {
if let Some(lang) = &self.lang { if let Some(lang) = &self.lang {
start.push_attribute(("xml:lang", lang.as_str())); start.push_attribute(("xml:lang", lang.as_str()));
} }
start.push_attribute(("xmlns", XMLNS::Client.into())); match &self.ns {
XMLNS::Client => start.push_attribute(("xmlns", XMLNS::Client.into())),
XMLNS::Server => start.push_attribute(("xmlns", XMLNS::Server.into())),
}
start.push_attribute(("xmlns:stream", XMLNS_STREAM)); start.push_attribute(("xmlns:stream", XMLNS_STREAM));
start start
} }
@ -129,7 +132,7 @@ impl<'e> TryFrom<Element<'e>> for Stream {
to, to,
version, version,
lang, lang,
_ns: ns, ns,
}) })
} else { } else {
Err(JabberError::ParseError) Err(JabberError::ParseError)