From c04005482737443c515416321dfb7035609fa812 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 15 Jan 2025 11:07:07 +0100 Subject: [PATCH] schema: add 'description' builder methods to schema types To cover the use case where we want to change only the description of an existing type. Signed-off-by: Wolfgang Bumiller --- proxmox-schema/src/schema.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/proxmox-schema/src/schema.rs b/proxmox-schema/src/schema.rs index 322a90c9..a8598a6c 100644 --- a/proxmox-schema/src/schema.rs +++ b/proxmox-schema/src/schema.rs @@ -198,6 +198,11 @@ impl BooleanSchema { } } + pub const fn description(mut self, description: &'static str) -> Self { + self.description = description; + self + } + pub const fn default(mut self, default: bool) -> Self { self.default = Some(default); self @@ -240,6 +245,11 @@ impl IntegerSchema { } } + pub const fn description(mut self, description: &'static str) -> Self { + self.description = description; + self + } + pub const fn default(mut self, default: isize) -> Self { self.default = Some(default); self @@ -316,6 +326,11 @@ impl NumberSchema { } } + pub const fn description(mut self, description: &'static str) -> Self { + self.description = description; + self + } + pub const fn default(mut self, default: f64) -> Self { self.default = Some(default); self @@ -420,6 +435,11 @@ impl StringSchema { } } + pub const fn description(mut self, description: &'static str) -> Self { + self.description = description; + self + } + pub const fn default(mut self, text: &'static str) -> Self { self.default = Some(text); self @@ -537,6 +557,11 @@ impl ArraySchema { } } + pub const fn description(mut self, description: &'static str) -> Self { + self.description = description; + self + } + pub const fn min_length(mut self, min_length: usize) -> Self { self.min_length = Some(min_length); self