[pbs-devel] [PATCH proxmox 1/1] schema: serialize enum unit variants

Hannes Laimer h.laimer at proxmox.com
Tue Aug 29 11:59:16 CEST 2023


... since deserializing them already works

Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
---
 proxmox-schema/src/ser/mod.rs | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/proxmox-schema/src/ser/mod.rs b/proxmox-schema/src/ser/mod.rs
index 3dad6d6..e19209a 100644
--- a/proxmox-schema/src/ser/mod.rs
+++ b/proxmox-schema/src/ser/mod.rs
@@ -483,14 +483,13 @@ impl<T: fmt::Write> Serializer for ElementSerializer<T> {
     }
 
     fn serialize_unit_variant(
-        self,
-        name: &'static str,
+        mut self,
+        _name: &'static str,
         _index: u32,
         variant: &'static str,
     ) -> Result<Self::Ok, Error> {
-        Err(Error::msg(format!(
-            "tried to serialize a unit variant ({name}::{variant})"
-        )))
+        self.inner.write_str(variant)?;
+        Ok(self.inner)
     }
 
     fn serialize_newtype_struct<V>(self, _name: &'static str, value: &V) -> Result<T, Error>
-- 
2.39.2






More information about the pbs-devel mailing list