diff --git a/object_store/Cargo.toml b/object_store/Cargo.toml index 0b40862c5c69..a1091450ed1c 100644 --- a/object_store/Cargo.toml +++ b/object_store/Cargo.toml @@ -24,7 +24,7 @@ readme = "README.md" description = "A generic object store interface for uniformly interacting with AWS S3, Google Cloud Storage, Azure Blob Storage and local files." keywords = ["object", "storage", "cloud"] repository = "https://github.com/apache/arrow-rs/tree/main/object_store" -rust-version = "1.64.0" +rust-version = "1.70.0" [package.metadata.docs.rs] all-features = true @@ -35,8 +35,8 @@ bytes = "1.0" chrono = { version = "0.4.34", default-features = false, features = ["clock"] } futures = "0.3" http = "1.2.0" -humantime = "2.1" itertools = "0.14.0" +jiff = { version = "0.2", default-features = false } parking_lot = { version = "0.12" } percent-encoding = "2.1" thiserror = "2.0.2" diff --git a/object_store/src/config.rs b/object_store/src/config.rs index 29a389d4e3dd..565df53fd06f 100644 --- a/object_store/src/config.rs +++ b/object_store/src/config.rs @@ -18,7 +18,7 @@ use std::fmt::{Debug, Display, Formatter}; use std::str::FromStr; use std::time::Duration; -use humantime::{format_duration, parse_duration}; +use jiff::SignedDuration; use reqwest::header::HeaderValue; use crate::{Error, Result}; @@ -87,10 +87,12 @@ impl Parse for bool { impl Parse for Duration { fn parse(v: &str) -> Result { - parse_duration(v).map_err(|_| Error::Generic { - store: "Config", - source: format!("failed to parse \"{v}\" as Duration").into(), - }) + SignedDuration::from_str(v) + .and_then(Self::try_from) + .map_err(|_| Error::Generic { + store: "Config", + source: format!("failed to parse \"{v}\" as Duration").into(), + }) } } @@ -123,7 +125,12 @@ impl Parse for HeaderValue { pub(crate) fn fmt_duration(duration: &ConfigValue) -> String { match duration { - ConfigValue::Parsed(v) => format_duration(*v).to_string(), + ConfigValue::Parsed(v) => { + // Should only fail if `Duration` has more seconds than what fits + // into i64. + let d = SignedDuration::try_from(*v).unwrap(); + format!("{:#}", d) + } ConfigValue::Deferred(v) => v.clone(), } } @@ -140,4 +147,13 @@ mod tests { assert_eq!(Duration::parse("60 s").unwrap(), duration); assert_eq!(Duration::parse("60s").unwrap(), duration) } + + #[test] + fn test_fmt_duration() { + let dur = ConfigValue::Parsed(Duration::new(9420, 0)); + assert_eq!("2h 37m", fmt_duration(&dur)); + + let dur = ConfigValue::Parsed(Duration::new(0, 32_000_000)); + assert_eq!("32ms", fmt_duration(&dur)); + } }