From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 5111C1FF13F for ; Thu, 12 Mar 2026 14:53:33 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8ABCC1791A; Thu, 12 Mar 2026 14:53:17 +0100 (CET) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Subject: [PATCH proxmox 09/26] disks: gate api macro behind 'api-types' feature Date: Thu, 12 Mar 2026 14:52:10 +0100 Message-ID: <20260312135229.420729-10-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260312135229.420729-1-l.wagner@proxmox.com> References: <20260312135229.420729-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1773323522907 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.047 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_MSPIKE_H2 0.001 Average reputation (+2) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: L4CSSF6VBZGLXLWAV5UX6T3NQKJYVNXW X-Message-ID-Hash: L4CSSF6VBZGLXLWAV5UX6T3NQKJYVNXW X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Some users of this crate don't need the derived API types, so it is best to gate it behind a feature. Signed-off-by: Lukas Wagner --- proxmox-disks/Cargo.toml | 6 +++++- proxmox-disks/src/lib.rs | 18 ++++++++++-------- proxmox-disks/src/smart.rs | 9 +++++---- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/proxmox-disks/Cargo.toml b/proxmox-disks/Cargo.toml index 29bf56fe..f581e464 100644 --- a/proxmox-disks/Cargo.toml +++ b/proxmox-disks/Cargo.toml @@ -26,5 +26,9 @@ proxmox-io.workspace = true proxmox-lang.workspace = true proxmox-log.workspace = true proxmox-parallel-handler.workspace = true -proxmox-schema = { workspace = true, features = [ "api-macro", "api-types" ] } +proxmox-schema = { workspace = true, features = [ "api-types" ], optional = true } proxmox-sys.workspace = true + +[features] +default = [ "dep:proxmox-schema" ] +api-types = [ "proxmox-schema/api-macro" ] diff --git a/proxmox-disks/src/lib.rs b/proxmox-disks/src/lib.rs index 4039b4cd..74907711 100644 --- a/proxmox-disks/src/lib.rs +++ b/proxmox-disks/src/lib.rs @@ -17,13 +17,15 @@ use ::serde::{Deserialize, Serialize}; use proxmox_lang::{io_bail, io_format_err}; use proxmox_log::info; use proxmox_parallel_handler::ParallelHandler; -use proxmox_schema::api; use proxmox_sys::linux::procfs::{mountinfo::Device, MountInfo}; use proxmox_schema::api_types::{ BLOCKDEVICE_DISK_AND_PARTITION_NAME_REGEX, BLOCKDEVICE_NAME_REGEX, UUID_REGEX, }; +#[cfg(feature = "api-types")] +use proxmox_schema::api; + mod zfs; pub use zfs::*; mod zpool_status; @@ -626,7 +628,7 @@ impl Disk { } } -#[api()] +#[cfg_attr(feature = "api-types", api)] #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] /// This is just a rough estimate for a "type" of disk. @@ -682,7 +684,7 @@ fn get_file_system_devices(lsblk_info: &[LsblkInfo]) -> Result, Err Ok(device_set) } -#[api()] +#[cfg_attr(feature = "api-types", api)] #[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] #[serde(rename_all = "lowercase")] /// What a block device partition is used for. @@ -703,7 +705,7 @@ pub enum PartitionUsageType { FileSystem, } -#[api()] +#[cfg_attr(feature = "api-types", api)] #[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] #[serde(rename_all = "lowercase")] /// What a block device (disk) is used for. @@ -724,7 +726,7 @@ pub enum DiskUsageType { FileSystem, } -#[api()] +#[cfg_attr(feature = "api-types", api)] #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] /// Basic information about a partition @@ -747,7 +749,7 @@ pub struct PartitionInfo { pub uuid: Option, } -#[api( +#[cfg_attr(feature = "api-types", api( properties: { used: { type: DiskUsageType, @@ -765,7 +767,7 @@ pub struct PartitionInfo { } } } -)] +))] #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] /// Information about how a Disk is used @@ -1302,7 +1304,7 @@ pub fn create_single_linux_partition(disk: &Disk) -> Result { } } -#[api()] +#[cfg_attr(feature = "api-types", api)] #[derive(Debug, Copy, Clone, Serialize, Deserialize, Eq, PartialEq)] #[serde(rename_all = "lowercase")] /// A file system type supported by our tooling. diff --git a/proxmox-disks/src/smart.rs b/proxmox-disks/src/smart.rs index 1d41cee2..247bc4d3 100644 --- a/proxmox-disks/src/smart.rs +++ b/proxmox-disks/src/smart.rs @@ -7,9 +7,10 @@ use std::{ use ::serde::{Deserialize, Serialize}; use anyhow::Error; +#[cfg(feature = "api-types")] use proxmox_schema::api; -#[api()] +#[cfg_attr(feature = "api-types", api)] #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] /// SMART status @@ -22,7 +23,7 @@ pub enum SmartStatus { Unknown, } -#[api()] +#[cfg_attr(feature = "api-types", api)] #[derive(Debug, Serialize, Deserialize)] /// SMART Attribute pub struct SmartAttribute { @@ -51,7 +52,7 @@ pub struct SmartAttribute { threshold: Option, } -#[api( +#[cfg_attr(feature = "api-types", api( properties: { status: { type: SmartStatus, @@ -69,7 +70,7 @@ pub struct SmartAttribute { }, }, }, -)] +))] #[derive(Debug, Serialize, Deserialize)] /// Data from smartctl pub struct SmartData { -- 2.47.3