[pbs-devel] [PATCH proxmox-backup v2 1/3] pbs-api-types: use SchemaDeserializer for maintenance mode

Christian Ebner c.ebner at proxmox.com
Fri Apr 19 11:42:12 CEST 2024


On 4/19/24 09:37, Dietmar Maurer wrote:
> Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
> Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
> ---
>   pbs-api-types/src/datastore.rs | 15 +++++++++------
>   1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs
> index 5e13c157..483cdef4 100644
> --- a/pbs-api-types/src/datastore.rs
> +++ b/pbs-api-types/src/datastore.rs
> @@ -11,8 +11,8 @@ use proxmox_schema::{
>   };
>   
>   use crate::{
> -    Authid, CryptMode, Fingerprint, GroupFilter, MaintenanceMode, Userid, BACKUP_ID_RE,
> -    BACKUP_NS_RE, BACKUP_TIME_RE, BACKUP_TYPE_RE, DATASTORE_NOTIFY_STRING_SCHEMA,
> +    Authid, CryptMode, Fingerprint, GroupFilter, MaintenanceMode, MaintenanceType, Userid,
> +    BACKUP_ID_RE, BACKUP_NS_RE, BACKUP_TIME_RE, BACKUP_TYPE_RE, DATASTORE_NOTIFY_STRING_SCHEMA,
>       GC_SCHEDULE_SCHEMA, GROUP_OR_SNAPSHOT_PATH_REGEX_STR, PROXMOX_SAFE_ID_FORMAT,
>       PROXMOX_SAFE_ID_REGEX_STR, PRUNE_SCHEDULE_SCHEMA, SHA256_HEX_REGEX, SINGLE_LINE_COMMENT_SCHEMA,
>       SNAPSHOT_PATH_REGEX_STR, UPID,
> @@ -336,10 +336,13 @@ impl DataStoreConfig {
>       }
>   
>       pub fn get_maintenance_mode(&self) -> Option<MaintenanceMode> {
> -        self.maintenance_mode
> -            .as_ref()
> -            .and_then(|str| MaintenanceMode::API_SCHEMA.parse_property_string(str).ok())
> -            .and_then(|value| MaintenanceMode::deserialize(value).ok())
> +        self.maintenance_mode.as_ref().and_then(|str| {
> +            MaintenanceMode::deserialize(proxmox_schema::de::SchemaDeserializer::new(

Should `SchemaDeserializer` be brought into scope by adding it to the 
already present `proxmox_schema` use statement?

> +                str,
> +                &MaintenanceMode::API_SCHEMA,
> +            ))
> +            .ok()
> +        })
>       }
>   }
>   





More information about the pbs-devel mailing list