[pbs-devel] [PATCH proxmox-backup v4 08/45] s3 client: add type for last modified timestamp in responses

Christian Ebner c.ebner at proxmox.com
Mon Jun 23 11:40:29 CEST 2025


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 at proxmox.com>
---
 Cargo.toml               |  2 ++
 pbs-s3-client/Cargo.toml |  2 ++
 pbs-s3-client/src/lib.rs | 20 ++++++++++++++++++++
 3 files changed, 24 insertions(+)

diff --git a/Cargo.toml b/Cargo.toml
index 5c69f249a..6c617989b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -133,6 +133,7 @@ hickory-resolver = { version = "0.24.1", default-features = false, features = [
 http-body-util = "0.1"
 hyper-util = "0.1"
 hyper = { version = "1", features = [ "full" ] }
+iso8601 = "0.6.1"
 libc = "0.2"
 log = "0.4.17"
 nix = "0.29"
@@ -146,6 +147,7 @@ regex = "1.5.5"
 rustyline = "14"
 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 146fde84e..d41cd8870 100644
--- a/pbs-s3-client/Cargo.toml
+++ b/pbs-s3-client/Cargo.toml
@@ -12,8 +12,10 @@ 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
 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 14f86bf88..8845b8f97 100644
--- a/pbs-s3-client/src/lib.rs
+++ b/pbs-s3-client/src/lib.rs
@@ -4,3 +4,23 @@ mod client;
 pub use client::{S3Client, S3ClientOptions, S3PathPrefix};
 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.47.2





More information about the pbs-devel mailing list