From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pbs-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 93A691FF170 for <inbox@lore.proxmox.com>; Thu, 29 May 2025 16:32:48 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9176415F69; Thu, 29 May 2025 16:32:56 +0200 (CEST) From: Christian Ebner <c.ebner@proxmox.com> To: pbs-devel@lists.proxmox.com Date: Thu, 29 May 2025 16:31:35 +0200 Message-Id: <20250529143207.694497-11-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250529143207.694497-1-c.ebner@proxmox.com> References: <20250529143207.694497-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.032 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 Subject: [pbs-devel] [RFC v2 proxmox-backup 10/42] 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 <pbs-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/> List-Post: <mailto:pbs-devel@lists.proxmox.com> List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox Backup Server development discussion <pbs-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" <pbs-devel-bounces@lists.proxmox.com> Adds a helper to parse modified timestamps as encountered in s3 list objects v2 and copy object api calls. Signed-off-by: Christian Ebner <c.ebner@proxmox.com> --- Cargo.toml | 2 ++ pbs-s3-client/Cargo.toml | 3 +++ pbs-s3-client/src/lib.rs | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index c2b0029ac..aaa79c2aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -131,6 +131,7 @@ handlebars = "3.0" hex = "0.4.3" hickory-resolver = { version = "0.24.1", default-features = false, features = [ "system-config", "tokio-runtime" ] } hyper = { version = "0.14", features = [ "backports", "deprecated", "full" ] } +iso8601 = "0.4.1" libc = "0.2" log = "0.4.17" nix = "0.26.1" @@ -144,6 +145,7 @@ regex = "1.5.5" rustyline = "9" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" +serde_plain = "1.0" siphasher = "0.3" syslog = "6" tar = "0.4" diff --git a/pbs-s3-client/Cargo.toml b/pbs-s3-client/Cargo.toml index 11189ea50..3261a32bb 100644 --- a/pbs-s3-client/Cargo.toml +++ b/pbs-s3-client/Cargo.toml @@ -10,7 +10,10 @@ rust-version.workspace = true anyhow.workspace = true hex = { workspace = true, features = [ "serde" ] } hyper.workspace = true +iso8601.workspace = true openssl.workspace = true +serde.workspace = true +serde_plain.workspace = true tracing.workspace = true url.workspace = true diff --git a/pbs-s3-client/src/lib.rs b/pbs-s3-client/src/lib.rs index a4081df15..dbe4bebcc 100644 --- a/pbs-s3-client/src/lib.rs +++ b/pbs-s3-client/src/lib.rs @@ -3,3 +3,23 @@ mod client; pub use client::{S3Client, S3ClientOptions}; mod object_key; pub use object_key::{S3ObjectKey, S3_CONTENT_PREFIX}; + +use std::time::Duration; + +use anyhow::{anyhow, bail, Error}; + +#[derive(Debug)] +pub struct LastModifiedTimestamp { + _datetime: iso8601::DateTime, +} + +impl std::str::FromStr for LastModifiedTimestamp { + type Err = Error; + + fn from_str(timestamp: &str) -> Result<Self, Self::Err> { + let _datetime = iso8601::datetime(timestamp).map_err(|err| anyhow!(err))?; + Ok(Self { _datetime }) + } +} + +serde_plain::derive_deserialize_from_fromstr!(LastModifiedTimestamp, "last modified timestamp"); -- 2.39.5 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel