Rewrite time module in pure Rust #125
Open
+2,314
−1,718
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The next chunk of changes from #122.
This re-implements the time related functionality in native Rust. This one is a bit larger, mostly from the fact that the conversions in the C implementation are very inter-dependent and so several new bits of functionality were pulled in to make the Rust implementation mirror the C implementation. There's a few bits of functionality thrown out because they caused some significant unsoundness, but I'm sure there is still several bits of unsoundness in this translation (e.g. several panics/asserts are still present). I'd prefer to keep this PR as close to a straight translation as possible, and re-consider the soundness concerns in a future PR.
What's been changed
What's been removed
GloTime
- GLONASS time is particularly complicated and rarely usedGpsTime::to_glo()
andGpsTime::to_glo_hardcoded()
- See aboveimpl Sub<GpsTime> for GpsTime
- It turns out astd::time::Duration
can't hold a negative value. This implementation would occasionally panic because of this. Thechrono
crate handles this better, maybe we can move towards their approach in a later PR?UtcParams::decode()
- Decoding low-level messages seem unlikely to be neededimpl Default for UtcParams
- Defaulting this data can cause unexpected errorsimpl Default for UtcTime
- Defaulting this type can cause unexpected errorsWhat's been added
time::consts
moduleGpsTime::from_date()
andGpsTime::from_date_hardcoded()
GpsTime::to_mjd()
andGpsTime::to_mjd_hardcoded()
GpsTime::to_date()
andGpsTime::to_date_hardcoded()
UtcTime::to_date()
MJD::to_gps()
andMJD::to_gps_hardcoded()
MJD::to_date()