This is an automated email from the ASF dual-hosted git repository.

Xuanwo pushed a commit to branch xuanwo/chore-upgrade-jiff-1
in repository https://gitbox.apache.org/repos/asf/opendal.git

commit 6058db0518c8e8f5da14e6dfddd8085996ed7599
Author: Xuanwo <[email protected]>
AuthorDate: Mon Nov 23 00:36:44 2026 +0100

    chore(deps): upgrade jiff to 1.0.1
    
    Upgrade opendal-core's jiff dependency from 0.2 to 1.0.1.
    
    Convert jiff::Timestamp to SystemTime with try_from while keeping OpenDAL's
    infallible From<Timestamp> for SystemTime. The Python binding keeps jiff 0.2
    for PyO3's jiff-02 conversions and bridges timestamps explicitly.
    
    Sync bindings/ruby/Cargo.lock and document the breaking change in 
upgrade.md.
---
 bindings/python/src/metadata.rs |  2 +-
 bindings/python/src/options.rs  | 24 +++++++++----
 bindings/python/src/utils.rs    | 26 +++++++++++++++
 bindings/ruby/Cargo.lock        | 62 +++++++++++++++++++++++++++++++---
 core/Cargo.lock                 | 74 +++++++++++++++++++++++++++++++++++------
 core/core/Cargo.toml            |  4 +--
 core/core/src/docs/upgrade.md   | 12 +++++++
 core/core/src/raw/time.rs       | 13 ++++++--
 8 files changed, 190 insertions(+), 27 deletions(-)

diff --git a/bindings/python/src/metadata.rs b/bindings/python/src/metadata.rs
index eedae51de1..1cb5c2ed6e 100644
--- a/bindings/python/src/metadata.rs
+++ b/bindings/python/src/metadata.rs
@@ -143,7 +143,7 @@ impl Metadata {
     /// The last modified timestamp of this entry.
     #[getter]
     pub fn last_modified(&self) -> Option<jiff::Timestamp> {
-        self.0.last_modified().map(Into::into)
+        self.0.last_modified().map(utils::timestamp_to_jiff)
     }
 
     /// The version of this entry.
diff --git a/bindings/python/src/options.rs b/bindings/python/src/options.rs
index 33a2767ab2..c66758df5b 100644
--- a/bindings/python/src/options.rs
+++ b/bindings/python/src/options.rs
@@ -194,8 +194,12 @@ impl From<ReadOptions> for ocore::options::ReadOptions {
             version: opts.version,
             if_match: opts.if_match,
             if_none_match: opts.if_none_match,
-            if_modified_since: opts.if_modified_since.map(Into::into),
-            if_unmodified_since: opts.if_unmodified_since.map(Into::into),
+            if_modified_since: opts
+                .if_modified_since
+                .map(crate::utils::timestamp_from_jiff),
+            if_unmodified_since: opts
+                .if_unmodified_since
+                .map(crate::utils::timestamp_from_jiff),
             content_length_hint: None,
             concurrent: opts.concurrent.unwrap_or_default(),
             chunk: opts.chunk,
@@ -214,8 +218,12 @@ impl From<ReadOptions> for ocore::options::ReaderOptions {
             version: opts.version,
             if_match: opts.if_match,
             if_none_match: opts.if_none_match,
-            if_modified_since: opts.if_modified_since.map(Into::into),
-            if_unmodified_since: opts.if_unmodified_since.map(Into::into),
+            if_modified_since: opts
+                .if_modified_since
+                .map(crate::utils::timestamp_from_jiff),
+            if_unmodified_since: opts
+                .if_unmodified_since
+                .map(crate::utils::timestamp_from_jiff),
             content_length_hint: None,
             concurrent: opts.concurrent.unwrap_or_default(),
             chunk: opts.chunk,
@@ -337,8 +345,12 @@ impl From<StatOptions> for ocore::options::StatOptions {
             version: opts.version,
             if_match: opts.if_match,
             if_none_match: opts.if_none_match,
-            if_modified_since: opts.if_modified_since.map(Into::into),
-            if_unmodified_since: opts.if_unmodified_since.map(Into::into),
+            if_modified_since: opts
+                .if_modified_since
+                .map(crate::utils::timestamp_from_jiff),
+            if_unmodified_since: opts
+                .if_unmodified_since
+                .map(crate::utils::timestamp_from_jiff),
             override_content_type: opts.content_type,
             override_cache_control: opts.cache_control,
             override_content_disposition: opts.content_disposition,
diff --git a/bindings/python/src/utils.rs b/bindings/python/src/utils.rs
index de2a31f170..bc612acc17 100644
--- a/bindings/python/src/utils.rs
+++ b/bindings/python/src/utils.rs
@@ -26,6 +26,22 @@ use pyo3::types::PyBytes;
 
 use crate::ocore;
 
+/// Convert a timestamp from this binding's `jiff` version to OpenDAL's.
+///
+/// PyO3's `jiff-02` feature keeps the Python binding on jiff 0.2, while
+/// `opendal-core` uses jiff 1.0. Both versions cover the same timestamp range.
+pub fn timestamp_from_jiff(ts: jiff::Timestamp) -> ocore::raw::Timestamp {
+    ocore::raw::Timestamp::new(ts.as_second(), ts.subsec_nanosecond())
+        .expect("jiff timestamp is within OpenDAL timestamp range")
+}
+
+/// Convert an OpenDAL timestamp to this binding's `jiff` version.
+pub fn timestamp_to_jiff(ts: ocore::raw::Timestamp) -> jiff::Timestamp {
+    let ts = ts.into_inner();
+    jiff::Timestamp::new(ts.as_second(), ts.subsec_nanosecond())
+        .expect("OpenDAL timestamp is within jiff timestamp range")
+}
+
 /// Keep immutable Python bytes alive inside an OpenDAL buffer without copying.
 pub fn py_bytes_like_into_buffer(value: &Bound<PyAny>) -> 
PyResult<ocore::Buffer> {
     if let Ok(value) = value.cast::<PyBytes>() {
@@ -106,6 +122,16 @@ mod tests {
 
     use super::*;
 
+    #[test]
+    fn test_timestamp_jiff_conversion_preserves_nanoseconds() {
+        let ts = jiff::Timestamp::new(1_646_122_354, 123_456_789).unwrap();
+        let opendal_ts = timestamp_from_jiff(ts);
+
+        assert_eq!(opendal_ts.into_inner().as_second(), 1_646_122_354);
+        assert_eq!(opendal_ts.into_inner().subsec_nanosecond(), 123_456_789);
+        assert_eq!(timestamp_to_jiff(opendal_ts), ts);
+    }
+
     #[test]
     fn test_buffer_into_py_bytes() {
         Python::initialize();
diff --git a/bindings/ruby/Cargo.lock b/bindings/ruby/Cargo.lock
index aa4d32ca58..2ba1171f97 100644
--- a/bindings/ruby/Cargo.lock
+++ b/bindings/ruby/Cargo.lock
@@ -1087,8 +1087,24 @@ source = 
"registry+https://github.com/rust-lang/crates.io-index";
 checksum = "961d16382652bfdd8c6f68b223b26a8c93e0d475c672f414411db31c6c5c900e"
 dependencies = [
  "defmt",
- "jiff-static",
- "jiff-tzdb-platform",
+ "jiff-static 0.2.32",
+ "jiff-tzdb-platform 0.1.3",
+ "log",
+ "portable-atomic",
+ "portable-atomic-util",
+ "serde_core",
+ "windows-link",
+]
+
+[[package]]
+name = "jiff"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "ed5d126d72eb017f10b302e73bdeca446bea405ee449af4d9e7866d6b082d83e"
+dependencies = [
+ "jiff-core",
+ "jiff-static 1.0.1",
+ "jiff-tzdb-platform 1.0.0",
  "js-sys",
  "log",
  "portable-atomic",
@@ -1098,6 +1114,15 @@ dependencies = [
  "windows-link",
 ]
 
+[[package]]
+name = "jiff-core"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "b6b46a105a9874634dd96231021526bf24ca04955a5998c59a9c7666e634b7b8"
+dependencies = [
+ "log",
+]
+
 [[package]]
 name = "jiff-static"
 version = "0.2.32"
@@ -1109,19 +1134,46 @@ dependencies = [
  "syn 2.0.118",
 ]
 
+[[package]]
+name = "jiff-static"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "c0127e9bde3c6130d6169e7d8d68676e4be69c4bf7573c308b6f960a5089c428"
+dependencies = [
+ "jiff-core",
+ "proc-macro2",
+ "quote",
+ "syn 3.0.3",
+]
+
 [[package]]
 name = "jiff-tzdb"
 version = "0.1.8"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "142bd39932ad231f10513df9ab62661fead8719872150b7ad02a2df79f4e141e"
 
+[[package]]
+name = "jiff-tzdb"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "12e71a1b68a875a44a33bb7a1dd84392cb77145a3367a552a3cfe6a4f5cf3afc"
+
 [[package]]
 name = "jiff-tzdb-platform"
 version = "0.1.3"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8"
 dependencies = [
- "jiff-tzdb",
+ "jiff-tzdb 0.1.8",
+]
+
+[[package]]
+name = "jiff-tzdb-platform"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "dc65b284afcfa8f6cf189c7274c805505314a7ab975c60e1f548bff56525420e"
+dependencies = [
+ "jiff-tzdb 1.0.0",
 ]
 
 [[package]]
@@ -1433,7 +1485,7 @@ dependencies = [
  "bytes",
  "futures",
  "http",
- "jiff",
+ "jiff 1.0.1",
  "log",
  "md-5",
  "percent-encoding",
@@ -2296,7 +2348,7 @@ dependencies = [
  "hex",
  "hmac 0.13.0",
  "http",
- "jiff",
+ "jiff 0.2.32",
  "log",
  "percent-encoding",
  "rsa",
diff --git a/core/Cargo.lock b/core/Cargo.lock
index 7e65f333ef..9b962d3bda 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -4150,7 +4150,7 @@ dependencies = [
  "bstr",
  "gix-error",
  "itoa",
- "jiff",
+ "jiff 0.2.35",
 ]
 
 [[package]]
@@ -5995,9 +5995,25 @@ source = 
"registry+https://github.com/rust-lang/crates.io-index";
 checksum = "668b7183bd07af9a4885f5c35b0cc5c83c4607a913c16b7e17291832910d2dcc"
 dependencies = [
  "defmt 1.1.0",
- "jiff-core",
- "jiff-static",
- "jiff-tzdb-platform",
+ "jiff-core 0.1.0",
+ "jiff-static 0.2.35",
+ "jiff-tzdb-platform 0.1.3",
+ "log",
+ "portable-atomic",
+ "portable-atomic-util",
+ "serde_core",
+ "windows-link",
+]
+
+[[package]]
+name = "jiff"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "ed5d126d72eb017f10b302e73bdeca446bea405ee449af4d9e7866d6b082d83e"
+dependencies = [
+ "jiff-core 1.0.1",
+ "jiff-static 1.0.1",
+ "jiff-tzdb-platform 1.0.0",
  "js-sys",
  "log",
  "portable-atomic",
@@ -6016,31 +6032,67 @@ dependencies = [
  "defmt 1.1.0",
 ]
 
+[[package]]
+name = "jiff-core"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "b6b46a105a9874634dd96231021526bf24ca04955a5998c59a9c7666e634b7b8"
+dependencies = [
+ "log",
+]
+
 [[package]]
 name = "jiff-static"
 version = "0.2.35"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "3a69dcb3a21cfb32ce1cd056169337ca284af0766dd766e7878819b251a49204"
 dependencies = [
- "jiff-core",
+ "jiff-core 0.1.0",
  "proc-macro2",
  "quote",
  "syn 2.0.118",
 ]
 
+[[package]]
+name = "jiff-static"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "c0127e9bde3c6130d6169e7d8d68676e4be69c4bf7573c308b6f960a5089c428"
+dependencies = [
+ "jiff-core 1.0.1",
+ "proc-macro2",
+ "quote",
+ "syn 3.0.3",
+]
+
 [[package]]
 name = "jiff-tzdb"
 version = "0.1.6"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "c900ef84826f1338a557697dc8fc601df9ca9af4ac137c7fb61d4c6f2dfd3076"
 
+[[package]]
+name = "jiff-tzdb"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "12e71a1b68a875a44a33bb7a1dd84392cb77145a3367a552a3cfe6a4f5cf3afc"
+
 [[package]]
 name = "jiff-tzdb-platform"
 version = "0.1.3"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8"
 dependencies = [
- "jiff-tzdb",
+ "jiff-tzdb 0.1.6",
+]
+
+[[package]]
+name = "jiff-tzdb-platform"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "dc65b284afcfa8f6cf189c7274c805505314a7ab975c60e1f548bff56525420e"
+dependencies = [
+ "jiff-tzdb 1.0.0",
 ]
 
 [[package]]
@@ -6364,7 +6416,7 @@ version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "80f4ed78a03a30c12285135d98330f0f5d53cb0019bd1ac6d66863dae72d8d52"
 dependencies = [
- "jiff",
+ "jiff 0.2.35",
  "logforth-core",
 ]
 
@@ -6403,7 +6455,7 @@ version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "9d86a105f8f32151ca1e0a6d4097d478badb02d5715239ba0fa431a188a5d966"
 dependencies = [
- "jiff",
+ "jiff 0.2.35",
  "logforth-core",
  "serde",
  "serde_json",
@@ -6416,7 +6468,7 @@ source = 
"registry+https://github.com/rust-lang/crates.io-index";
 checksum = "4eafe007ac55293d807e8c7f5a23002e2518d32e476e195443cde23e7845416a"
 dependencies = [
  "colored",
- "jiff",
+ "jiff 0.2.35",
  "logforth-core",
 ]
 
@@ -7430,7 +7482,7 @@ dependencies = [
  "bytes",
  "futures",
  "http 1.5.0",
- "jiff",
+ "jiff 1.0.1",
  "log",
  "logforth",
  "md-5 0.11.0",
@@ -10499,7 +10551,7 @@ dependencies = [
  "hex",
  "hmac 0.13.0",
  "http 1.5.0",
- "jiff",
+ "jiff 0.2.35",
  "log",
  "percent-encoding",
  "rsa 0.9.10",
diff --git a/core/core/Cargo.toml b/core/core/Cargo.toml
index 1839de9219..7016595617 100644
--- a/core/core/Cargo.toml
+++ b/core/core/Cargo.toml
@@ -71,7 +71,7 @@ base64 = { workspace = true }
 bytes = { workspace = true }
 futures = { workspace = true, features = ["std", "async-await"] }
 http = { workspace = true }
-jiff = { version = "0.2.28", features = ["serde"] }
+jiff = { version = "1.0.1", features = ["serde"] }
 log = { workspace = true }
 md-5 = "0.11.0"
 percent-encoding = "2"
@@ -84,7 +84,7 @@ url = { workspace = true }
 uuid = { workspace = true, features = ["serde", "v4"] }
 
 [target.'cfg(target_arch = "wasm32")'.dependencies]
-jiff = { version = "0.2.28", features = ["serde", "js"] }
+jiff = { version = "1.0.1", features = ["serde", "js"] }
 tokio = { workspace = true, features = ["time"] }
 uuid = { workspace = true, features = ["serde", "v4", "js"] }
 
diff --git a/core/core/src/docs/upgrade.md b/core/core/src/docs/upgrade.md
index 166d494737..491984cb87 100644
--- a/core/core/src/docs/upgrade.md
+++ b/core/core/src/docs/upgrade.md
@@ -63,6 +63,18 @@ with `SignedDuration::from_secs(5)` or parse a duration 
string. The builder
 setters still accept `std::time::Duration`, and string/map configuration still
 accepts duration strings such as `"5s"`.
 
+## `jiff` upgraded to 1.0
+
+OpenDAL now uses `jiff` 1.0. The `jiff::Timestamp` and `jiff::SignedDuration`
+types re-exported from `opendal::raw` are now jiff 1.0 types. If your code uses
+these re-exports directly, upgrade your direct `jiff` dependency to `1.0`.
+jiff 1.0 requires Rust 1.85, which is below OpenDAL's minimum supported Rust
+version.
+
+`SystemTime::from(opendal::raw::Timestamp)` remains infallible. jiff 1.0 makes
+converting a `jiff::Timestamp` to `SystemTime` fallible, so use
+`SystemTime::try_from(timestamp)` for that conversion.
+
 ## Tokio executor moved to `opendal-executor-tokio`
 
 If you depend directly on `opendal-core`, remove its `executors-tokio` feature
diff --git a/core/core/src/raw/time.rs b/core/core/src/raw/time.rs
index 4ff95f4463..4ce5e0a2a0 100644
--- a/core/core/src/raw/time.rs
+++ b/core/core/src/raw/time.rs
@@ -180,16 +180,19 @@ impl From<jiff::Timestamp> for Timestamp {
 
 impl From<Timestamp> for SystemTime {
     fn from(ts: Timestamp) -> Self {
+        // jiff's `Timestamp` range fits in `SystemTime` on supported 
platforms,
+        // so keep this public conversion infallible despite jiff 1.0 making it
+        // fallible.
         #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
         {
-            SystemTime::from(ts.0)
+            SystemTime::try_from(ts.0).expect("jiff timestamp should fit in 
SystemTime")
         }
 
         #[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
         {
             use std::time::SystemTime as StdSystemTime;
 
-            let t = StdSystemTime::from(ts.0);
+            let t = StdSystemTime::try_from(ts.0).expect("jiff timestamp 
should fit in SystemTime");
             <web_time::SystemTime as web_time::web::SystemTimeExt>::from_std(t)
         }
     }
@@ -311,6 +314,12 @@ mod tests {
         assert_eq!("Sat, 29 Oct 1994 19:43:31 GMT", v.format_http_date());
     }
 
+    #[test]
+    fn test_min_and_max_timestamps_convert_to_system_time() {
+        let _: SystemTime = Timestamp::MIN.into();
+        let _: SystemTime = Timestamp::MAX.into();
+    }
+
     #[test]
     fn test_signed_duration_to_duration_rejects_negative_values() {
         
assert!(signed_duration_to_duration(SignedDuration::from_secs(-1)).is_err());

Reply via email to