From 2cfa31a218b2182ae347323b37216952d521efcf Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Wed, 13 Dec 2023 11:11:12 +0100 Subject: [PATCH] tape: fix 'eject-before-unload' api type by converting the bool into an option, otherwise having the options not set at all will fail the unload while deserializing with 'eject-before-unload is not optional' Also if we can automatically decide this in the future, we can now detect if the option was explicitely set or not. Fixes: 99f24b20 ("fix #4904: tape changer: add option to eject before unload") Signed-off-by: Dominik Csapak --- pbs-api-types/src/tape/changer.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pbs-api-types/src/tape/changer.rs b/pbs-api-types/src/tape/changer.rs index e3cf27c1..9e36b12e 100644 --- a/pbs-api-types/src/tape/changer.rs +++ b/pbs-api-types/src/tape/changer.rs @@ -39,18 +39,21 @@ Import/Export, i.e. any media in those slots are considered to be .format(&ApiStringFormat::PropertyString(&SLOT_ARRAY_SCHEMA)) .schema(); -fn is_false(b: &bool) -> bool { - !b -} - -#[api] +#[api( + properties: { + "eject-before-unload": { + optional: true, + default: false, + }, + }, +)] #[derive(Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] /// Options for Changers pub struct ChangerOptions { - #[serde(default, skip_serializing_if = "is_false")] + #[serde(skip_serializing_if = "Option::is_none")] /// if set to true, tapes are ejected manually before unloading - pub eject_before_unload: bool, + pub eject_before_unload: Option, } pub const CHANGER_OPTIONS_STRING_SCHEMA: Schema = StringSchema::new("Changer options")