[pdm-devel] [PATCH datacenter-manager v5 02/26] lib: api-types: add 'layout' property to ViewConfig

Dominik Csapak d.csapak at proxmox.com
Wed Nov 26 16:17:55 CET 2025


this is a simple string that holds the layout json. We can't currently
add it as a normal property with 'correct' api types, since we want to
use enum features that are not available with the api macro.

Multiple reasons why we can't use the correct type here (currently):
* our api macro does not support enum variants with struct types
  (so e.g. `Foo { bar: usize }`) so we can't generate an api schema for
  it.
* using something generic like a `Value` does not work since that does
  not impl our UpdaterType and we can't here because of the orphan rule.
* we could try to use a wrapper type around `Value` and implement
  the `UpdaterType` and `ApiType` ourselves, but the section config
  won't parse more complex types like an `ObjectSchema`

So until these are possible, our best bet is to simply use a string
and be careful what we accept (like parsing into the wanted type
during parsing/updating).

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes from v4:
* adapted to lukas' changes: no need to adapt the tests anymore
 lib/pdm-api-types/src/views.rs | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/pdm-api-types/src/views.rs b/lib/pdm-api-types/src/views.rs
index 82ab8781..30da7476 100644
--- a/lib/pdm-api-types/src/views.rs
+++ b/lib/pdm-api-types/src/views.rs
@@ -47,7 +47,10 @@ pub const FILTER_RULE_LIST_SCHEMA: Schema =
         "exclude": {
             schema: FILTER_RULE_LIST_SCHEMA,
             optional: true,
-        }
+        },
+        layout: {
+            optional: true,
+        },
     }
 )]
 #[derive(Clone, Debug, Default, Deserialize, Serialize, Updater, PartialEq)]
@@ -70,6 +73,13 @@ pub struct ViewConfig {
     #[serde(default, skip_serializing_if = "Vec::is_empty")]
     #[updater(serde(skip_serializing_if = "Option::is_none"))]
     pub exclude: Vec<FilterRule>,
+
+    // we can't currently describe this with the 'api' macro so save
+    // it simply as a string and check it in the add/update call
+    /// The configured layout, encoded as json
+    #[serde(default, skip_serializing_if = "String::is_empty")]
+    #[updater(serde(skip_serializing_if = "Option::is_none"))]
+    pub layout: String,
 }
 
 #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
-- 
2.47.3





More information about the pdm-devel mailing list