]> git.proxmox.com Git - proxmox.git/commitdiff
schema: serialize enum unit variants
authorHannes Laimer <h.laimer@proxmox.com>
Tue, 29 Aug 2023 09:59:16 +0000 (11:59 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 7 Sep 2023 15:29:36 +0000 (17:29 +0200)
... since deserializing them already works

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
proxmox-schema/src/ser/mod.rs

index 3dad6d68321a74637e25e242b698b320855f978c..e19209a8486ff0c61b37657a0781b091bf9fc208 100644 (file)
@@ -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>