From 880194d8119c222386e4461ce6bd03d43751c3a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?cel=20=F0=9F=8C=B8?= Date: Sun, 24 Nov 2024 15:09:05 +0000 Subject: [PATCH] fix: use namespace_declaration_overrides --- src/stanza/starttls.rs | 23 ++++------------------- src/stanza/stream.rs | 10 +++++----- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/stanza/starttls.rs b/src/stanza/starttls.rs index 874ae66..ee35bf5 100644 --- a/src/stanza/starttls.rs +++ b/src/stanza/starttls.rs @@ -21,7 +21,7 @@ impl IntoElement for StartTls { namespace: Some(XMLNS.to_string()), local_name: "required".to_string(), }, - namespace_declarations: HashSet::new(), + namespace_declaration_overrides: HashSet::new(), attributes: HashMap::new(), content: Vec::new(), }); @@ -29,17 +29,12 @@ impl IntoElement for StartTls { } else { content = Vec::new(); } - let mut namespace_declarations = HashSet::new(); - namespace_declarations.insert(NamespaceDeclaration { - prefix: None, - namespace: XMLNS.to_string(), - }); Element { name: Name { namespace: Some(XMLNS.to_string()), local_name: "starttls".to_string(), }, - namespace_declarations, + namespace_declaration_overrides: HashSet::new(), attributes: HashMap::new(), content, } @@ -90,17 +85,12 @@ pub struct Proceed; impl IntoElement for Proceed { fn into_element(&self) -> Element { - let mut namespace_declarations = HashSet::new(); - namespace_declarations.insert(NamespaceDeclaration { - prefix: None, - namespace: XMLNS.to_string(), - }); Element { name: Name { namespace: Some(XMLNS.to_string()), local_name: "proceed".to_string(), }, - namespace_declarations, + namespace_declaration_overrides: HashSet::new(), attributes: HashMap::new(), content: Vec::new(), } @@ -128,17 +118,12 @@ pub struct Failure; impl IntoElement for Failure { fn into_element(&self) -> Element { - let mut namespace_declarations = HashSet::new(); - namespace_declarations.insert(NamespaceDeclaration { - prefix: None, - namespace: XMLNS.to_string(), - }); Element { name: Name { namespace: Some(XMLNS.to_string()), local_name: "failure".to_string(), }, - namespace_declarations, + namespace_declaration_overrides: HashSet::new(), attributes: HashMap::new(), content: Vec::new(), } diff --git a/src/stanza/stream.rs b/src/stanza/stream.rs index 4516682..a5201dc 100644 --- a/src/stanza/stream.rs +++ b/src/stanza/stream.rs @@ -62,12 +62,12 @@ impl FromElement for Stream { impl IntoElement for Stream { fn into_element(&self) -> Element { - let mut namespace_declarations = HashSet::new(); - namespace_declarations.insert(NamespaceDeclaration { + let mut namespace_declaration_overrides = HashSet::new(); + namespace_declaration_overrides.insert(NamespaceDeclaration { prefix: Some("stream".to_string()), namespace: XMLNS.to_string(), }); - namespace_declarations.insert(NamespaceDeclaration { + namespace_declaration_overrides.insert(NamespaceDeclaration { prefix: None, // TODO: don't default to client namespace: XMLNS_CLIENT.to_string(), @@ -125,7 +125,7 @@ impl IntoElement for Stream { namespace: Some(XMLNS.to_string()), local_name: "stream".to_string(), }, - namespace_declarations, + namespace_declaration_overrides, attributes, content: Vec::new(), } @@ -185,7 +185,7 @@ impl IntoElement for Features { namespace: Some(XMLNS.to_string()), local_name: "features".to_string(), }, - namespace_declarations: HashSet::new(), + namespace_declaration_overrides: HashSet::new(), attributes: HashMap::new(), content, }