From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 2FFB91FF16F for ; Tue, 8 Jul 2025 19:00:56 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 52C221C2AF; Tue, 8 Jul 2025 19:01:37 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Tue, 8 Jul 2025 19:00:32 +0200 Message-ID: <20250708170114.1556057-5-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250708170114.1556057-1-c.ebner@proxmox.com> References: <20250708170114.1556057-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.040 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 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. [timestamps.rs, lib.rs] Subject: [pbs-devel] [PATCH proxmox v6 4/9] s3 client: add type for last modified timestamp in responses 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Adds a helper to parse modified timestamps as encountered in s3 list objects v2 and copy object api calls. Signed-off-by: Christian Ebner --- Cargo.toml | 1 + proxmox-s3-client/Cargo.toml | 2 ++ proxmox-s3-client/debian/control | 4 ++++ proxmox-s3-client/src/lib.rs | 4 ++++ proxmox-s3-client/src/timestamps.rs | 18 ++++++++++++++++++ 5 files changed, 29 insertions(+) create mode 100644 proxmox-s3-client/src/timestamps.rs diff --git a/Cargo.toml b/Cargo.toml index dc021796..cf0ef097 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,6 +92,7 @@ http-body = "1" http-body-util = "0.1" hyper = "1" hyper-util = "0.1.12" +iso8601 = "0.6.1" ldap3 = { version = "0.11", default-features = false } lettre = "0.11.1" libc = "0.2.107" diff --git a/proxmox-s3-client/Cargo.toml b/proxmox-s3-client/Cargo.toml index 31deca59..f5b87493 100644 --- a/proxmox-s3-client/Cargo.toml +++ b/proxmox-s3-client/Cargo.toml @@ -18,9 +18,11 @@ hex = { workspace = true, features = [ "serde" ] } http-body-util.workspace = true hyper-util = { workspace = true, features = [ "client-legacy", "tokio", "http1" ] } hyper.workspace = true +iso8601.workspace = true openssl.workspace = true regex.workspace = true serde.workspace = true +serde_plain.workspace = true tracing.workspace = true url.workspace = true diff --git a/proxmox-s3-client/debian/control b/proxmox-s3-client/debian/control index 0efb54db..f3ffa2d9 100644 --- a/proxmox-s3-client/debian/control +++ b/proxmox-s3-client/debian/control @@ -16,6 +16,7 @@ Build-Depends-Arch: cargo:native , librust-hyper-util-0.1+default-dev (>= 0.1.12-~~) , librust-hyper-util-0.1+http1-dev (>= 0.1.12-~~) , librust-hyper-util-0.1+tokio-dev (>= 0.1.12-~~) , + librust-iso8601-0.6+default-dev (>= 0.6.1-~~) , librust-openssl-0.10+default-dev , librust-proxmox-base64-1+default-dev , librust-proxmox-http-1+body-dev , @@ -31,6 +32,7 @@ Build-Depends-Arch: cargo:native , librust-proxmox-time-2+default-dev (>= 2.1.0-~~) , librust-regex-1+default-dev (>= 1.5-~~) , librust-serde-1+default-dev , + librust-serde-plain-1+default-dev , librust-tracing-0.1+default-dev , librust-url-2+default-dev (>= 2.2-~~) Maintainer: Proxmox Support Team @@ -56,6 +58,7 @@ Depends: librust-hyper-util-0.1+default-dev (>= 0.1.12-~~), librust-hyper-util-0.1+http1-dev (>= 0.1.12-~~), librust-hyper-util-0.1+tokio-dev (>= 0.1.12-~~), + librust-iso8601-0.6+default-dev (>= 0.6.1-~~), librust-openssl-0.10+default-dev, librust-proxmox-base64-1+default-dev, librust-proxmox-http-1+body-dev, @@ -71,6 +74,7 @@ Depends: librust-proxmox-time-2+default-dev (>= 2.1.0-~~), librust-regex-1+default-dev (>= 1.5-~~), librust-serde-1+default-dev, + librust-serde-plain-1+default-dev, librust-tracing-0.1+default-dev, librust-url-2+default-dev (>= 2.2-~~) Provides: diff --git a/proxmox-s3-client/src/lib.rs b/proxmox-s3-client/src/lib.rs index 7286cbd1..fc314c42 100644 --- a/proxmox-s3-client/src/lib.rs +++ b/proxmox-s3-client/src/lib.rs @@ -15,6 +15,10 @@ mod client; #[cfg(feature = "impl")] pub use client::{S3Client, S3ClientOptions}; #[cfg(feature = "impl")] +mod timestamps; +#[cfg(feature = "impl")] +pub use timestamps::*; +#[cfg(feature = "impl")] mod object_key; #[cfg(feature = "impl")] pub use object_key::S3ObjectKey; diff --git a/proxmox-s3-client/src/timestamps.rs b/proxmox-s3-client/src/timestamps.rs new file mode 100644 index 00000000..3713b6d0 --- /dev/null +++ b/proxmox-s3-client/src/timestamps.rs @@ -0,0 +1,18 @@ +use anyhow::{anyhow, Error}; + +#[derive(Debug)] +/// Last modified timestamp as obtained from API response http headers. +pub struct LastModifiedTimestamp { + _datetime: iso8601::DateTime, +} + +impl std::str::FromStr for LastModifiedTimestamp { + type Err = Error; + + fn from_str(timestamp: &str) -> Result { + let _datetime = iso8601::datetime(timestamp).map_err(|err| anyhow!(err))?; + Ok(Self { _datetime }) + } +} + +serde_plain::derive_deserialize_from_fromstr!(LastModifiedTimestamp, "last modified timestamp"); -- 2.47.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel