Skip to content

Commit 0f7e2cd

Browse files
Replace iso8601-duration with iso8601 crate
For one, this updates the indirect dependency `nom` from 5.x to 7.x, which gets rid of a future incompatibility warning produced by the compiler: warning: the following packages contain code that will be rejected by a future version of Rust: nom v5.1.2 note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 67` But to achieve that I could have updated `iso8601-duration` to 0.2. However, the 0.2 version makes conversion into an `std::time::Duration` weirdly hard. And I'm also confused by the fields being `f32` for no reason I can think of. Additionally, the crate has very few users and there is no changelog. So in general, the `iso8601` crate looks much better. Even if it gives us date parsing, which we don't need, I think it's still a better option. Unfortunately, the new crate only has millisecond precision whereas the previous one could store seconds as `f32`.
1 parent 94b25ea commit 0f7e2cd

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ members = ["examples/*"]
1313

1414
[dependencies]
1515
async-trait = "0.1.51"
16-
iso8601-duration = "0.1.0"
16+
iso8601 = "0.6.1"
1717
log = "0.4"
1818
serde = { version = "1.0", features = ["derive"] }
1919
serde_json = "1.0"

src/tasks.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ where
137137
D: Deserializer<'de>,
138138
{
139139
let s = String::deserialize(deserializer)?;
140-
let iso_duration = iso8601_duration::Duration::parse(&s).map_err(serde::de::Error::custom)?;
141-
Ok(iso_duration.to_std())
140+
let iso_duration = iso8601::duration(&s).map_err(serde::de::Error::custom)?;
141+
Ok(iso_duration.into())
142142
}
143143

144144
#[derive(Deserialize, Debug, Clone)]
@@ -809,7 +809,7 @@ mod test {
809809
..
810810
}
811811
}
812-
if duration == Duration::from_secs_f32(10.848957061)
812+
if duration == Duration::from_millis(10_848)
813813
));
814814
}
815815

0 commit comments

Comments
 (0)