fix: set quote level to full for xml serialization

also remove use of intermediate String
This commit is contained in:
Gwen Lg
2026-02-16 12:33:04 +01:00
committed by Alex
parent 1ae4e5d438
commit 6591044c2e
+5 -2
View File
@@ -1,11 +1,14 @@
use quick_xml::se::to_string; use quick_xml::se::{self, QuoteLevel};
use serde::{Deserialize, Serialize, Serializer}; use serde::{Deserialize, Serialize, Serializer};
use crate::error::Error as ApiError; use crate::error::Error as ApiError;
pub fn to_xml_with_header<T: Serialize>(x: &T) -> Result<String, ApiError> { pub fn to_xml_with_header<T: Serialize>(x: &T) -> Result<String, ApiError> {
let mut xml = r#"<?xml version="1.0" encoding="UTF-8"?>"#.to_string(); let mut xml = r#"<?xml version="1.0" encoding="UTF-8"?>"#.to_string();
xml.push_str(&to_string(x)?);
let mut ser = se::Serializer::new(&mut xml);
ser.set_quote_level(QuoteLevel::Full);
let _serialized = x.serialize(ser)?;
Ok(xml) Ok(xml)
} }