-
Notifications
You must be signed in to change notification settings - Fork 102
Replace iso8601-duration with iso8601 crate
#461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace iso8601-duration with iso8601 crate
#461
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, yeah, that looks like a good idea! Thanks for your research
|
The CI failure doesn't seem to have anything to do with my changes, right? |
|
bors try |
tryBuild failed: |
|
This is weird, the CI seems to run properly on the other PR's. What happens if you run your test locally? |
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`.
a7b38f4 to
0f7e2cd
Compare
|
Oh sorry, should have replied here sooner. Yes the CI failure is my fault. When I sent my last comment I was only on phone. But now I could reproduce the problem locally. The problem is that the new crate If not, then... oof. So |
|
Hey, I don't think it helps but just fyi, here is the code we use in meilisearch to serialize the duration; https://github.com/meilisearch/meilisearch/blob/fb9d9239b2113f21747b64f6c64f1d3014ed79c2/meilisearch-types/src/tasks.rs#L509-L558 It initially comes from time 0.2. |
|
Mh okay, so sub-millisecond durations are serialized. So if this library would just store milliseconds, that would mean a loss in precision. That said, with the old library and Again, neither is really good, but it's your call whether millisecond precision suffices for this Rust integration. (Speaking as a user of the library: while I would probably think "oh gosh, why the heck does the integration give me worse precision?", I don't need higher precision. I can't imagine someone needing more than ms precision.) If you prefer a solution without loss in precision, I can also hand code a deserialization function in this library. Might not be that terribly difficult. |
|
Hey @LukasKalbertodt We discussed it and decided that your suggestion is a good enhancement :) Thanks a lot for it 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors merge
|
Build succeeded:
|
Pull Request
Related issue
Fixes #<issue_number>
What does this PR do?
Replace
iso8601-durationwithiso8601crate.For one, this updates the indirect dependency
nomfrom 5.x to 7.x, which gets rid of a future incompatibility warning produced by the compiler:But to achieve that I could have updated
iso8601-durationto 0.2. However, the 0.2 version makes conversion into anstd::time::Durationweirdly hard. And I'm also confused by the fields beingf32for no reason I can think of. Additionally, the crate has very few users and there is no changelog. So in general, theiso8601crate looks much better. Even if it gives us date parsing, which we don't need, I think it's still a better option.PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!