[pbs-devel] [PATCH proxmox v6 4/9] s3 client: add type for last modified timestamp in responses
Christian Ebner
c.ebner at proxmox.com
Tue Jul 8 19:00:32 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 | 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 <!nocheck>,
librust-hyper-util-0.1+default-dev (>= 0.1.12-~~) <!nocheck>,
librust-hyper-util-0.1+http1-dev (>= 0.1.12-~~) <!nocheck>,
librust-hyper-util-0.1+tokio-dev (>= 0.1.12-~~) <!nocheck>,
+ librust-iso8601-0.6+default-dev (>= 0.6.1-~~) <!nocheck>,
librust-openssl-0.10+default-dev <!nocheck>,
librust-proxmox-base64-1+default-dev <!nocheck>,
librust-proxmox-http-1+body-dev <!nocheck>,
@@ -31,6 +32,7 @@ Build-Depends-Arch: cargo:native <!nocheck>,
librust-proxmox-time-2+default-dev (>= 2.1.0-~~) <!nocheck>,
librust-regex-1+default-dev (>= 1.5-~~) <!nocheck>,
librust-serde-1+default-dev <!nocheck>,
+ librust-serde-plain-1+default-dev <!nocheck>,
librust-tracing-0.1+default-dev <!nocheck>,
librust-url-2+default-dev (>= 2.2-~~) <!nocheck>
Maintainer: Proxmox Support Team <support at proxmox.com>
@@ -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<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