From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 4ED6B848A1 for ; Tue, 14 Dec 2021 13:24:45 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 47265242C3 for ; Tue, 14 Dec 2021 13:24:15 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 16874242AB for ; Tue, 14 Dec 2021 13:24:14 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id DDD98451AF for ; Tue, 14 Dec 2021 13:24:13 +0100 (CET) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Tue, 14 Dec 2021 13:24:04 +0100 Message-Id: <20211214122412.4077902-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211214122412.4077902-1-d.csapak@proxmox.com> References: <20211214122412.4077902-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.177 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [mod.rs] Subject: [pbs-devel] [PATCH proxmox 1/3] proxmox-sys: make some structs serializable X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Dec 2021 12:24:45 -0000 we already depend on serde anyway, and this makes gathering structs a bit more comfortable Signed-off-by: Dominik Csapak --- proxmox-sys/Cargo.toml | 1 + proxmox-sys/src/linux/procfs/mod.rs | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/proxmox-sys/Cargo.toml b/proxmox-sys/Cargo.toml index 80d39eb..bfcd388 100644 --- a/proxmox-sys/Cargo.toml +++ b/proxmox-sys/Cargo.toml @@ -17,6 +17,7 @@ log = "0.4" nix = "0.19.1" regex = "1.2" serde_json = "1.0" +serde = { version = "1.0", features = [ "derive" ] } zstd = { version = "0.6", features = [ "bindgen" ] } # Macro crates: diff --git a/proxmox-sys/src/linux/procfs/mod.rs b/proxmox-sys/src/linux/procfs/mod.rs index 30b9978..3373dec 100644 --- a/proxmox-sys/src/linux/procfs/mod.rs +++ b/proxmox-sys/src/linux/procfs/mod.rs @@ -11,6 +11,7 @@ use std::time::Instant; use anyhow::{bail, format_err, Error}; use lazy_static::lazy_static; use nix::unistd::Pid; +use serde::Serialize; use crate::fs::file_read_firstline; @@ -184,7 +185,7 @@ pub fn read_proc_uptime_ticks() -> Result<(u64, u64), Error> { Ok((up as u64, idle as u64)) } -#[derive(Debug, Default)] +#[derive(Debug, Default, Serialize)] /// The CPU fields from `/proc/stat` with their native time value. Multiply /// with CLOCK_TICKS to get the real value. pub struct ProcFsStat { @@ -407,7 +408,7 @@ fn test_read_proc_stat() { assert_eq!(stat.iowait_percent, 0.0); } -#[derive(Debug)] +#[derive(Debug, Serialize)] pub struct ProcFsMemInfo { pub memtotal: u64, pub memfree: u64, @@ -539,7 +540,7 @@ pub fn read_memory_usage() -> Result { } } -#[derive(Debug)] +#[derive(Debug, Serialize)] pub struct ProcFsNetDev { pub device: String, pub receive: u64, -- 2.30.2