From 32b616fd752dc1ffc7c669be073c30e0491f041c Mon Sep 17 00:00:00 2001
From: Lennart <18233294+lennart-k@users.noreply.github.com>
Date: Thu, 10 Jul 2025 15:45:07 +0200
Subject: [PATCH] xml serialize_to_string: Enable indentation
---
crates/dav/src/xml/resourcetype.rs | 8 +++++++-
crates/xml/src/se.rs | 2 +-
crates/xml/tests/se_enum.rs | 7 ++++++-
crates/xml/tests/se_struct.rs | 20 ++++++++++++++++----
4 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/crates/dav/src/xml/resourcetype.rs b/crates/dav/src/xml/resourcetype.rs
index cf6b912..e5bde00 100644
--- a/crates/dav/src/xml/resourcetype.rs
+++ b/crates/dav/src/xml/resourcetype.rs
@@ -33,7 +33,13 @@ mod tests {
.unwrap();
assert_eq!(
out,
- "\n"
+ r#"
+
+
+
+
+
+"#
)
}
}
diff --git a/crates/xml/src/se.rs b/crates/xml/src/se.rs
index da3faab..ebc3c6d 100644
--- a/crates/xml/src/se.rs
+++ b/crates/xml/src/se.rs
@@ -43,7 +43,7 @@ pub trait XmlSerializeRoot {
fn serialize_to_string(&self) -> std::io::Result {
let mut buf: Vec<_> = b"\n".into();
- let mut writer = quick_xml::Writer::new(&mut buf);
+ let mut writer = quick_xml::Writer::new_with_indent(&mut buf, b' ', 4);
self.serialize_root(&mut writer)?;
Ok(String::from_utf8_lossy(&buf).to_string())
}
diff --git a/crates/xml/tests/se_enum.rs b/crates/xml/tests/se_enum.rs
index d93e3b9..639b73d 100644
--- a/crates/xml/tests/se_enum.rs
+++ b/crates/xml/tests/se_enum.rs
@@ -22,6 +22,11 @@ fn test_struct_value_tagged() {
.unwrap();
assert_eq!(
out,
- "\nasd"
+ r#"
+
+
+ asd
+
+"#
);
}
diff --git a/crates/xml/tests/se_struct.rs b/crates/xml/tests/se_struct.rs
index a8c600c..dd7f75a 100644
--- a/crates/xml/tests/se_struct.rs
+++ b/crates/xml/tests/se_struct.rs
@@ -71,7 +71,11 @@ fn test_struct_value_tagged() {
.unwrap();
assert_eq!(
out,
- "\nokay123"
+ r#"
+
+ okay
+ 123
+"#
);
}
@@ -91,7 +95,8 @@ fn test_struct_value_untagged() {
.unwrap();
assert_eq!(
out,
- "\nokays"
+ r#"
+okays"#
);
}
@@ -111,7 +116,11 @@ fn test_struct_vec() {
.unwrap();
assert_eq!(
out,
- "\nokaywow"
+ r#"
+
+ okay
+ wow
+"#
);
}
@@ -141,7 +150,10 @@ fn test_struct_serialize_with() {
.unwrap();
assert_eq!(
out,
- "\nOKAY"
+ r#"
+
+ OKAY
+"#
);
}