Skip to content
This repository has been archived by the owner on May 18, 2022. It is now read-only.

Remove byteorder dependency #124

Merged
merged 2 commits into from
Jul 10, 2020

Conversation

daboross
Copy link
Contributor

I included a fix for the last remaining header not implementing FromBytes/ToBytes in this PR, as that made removing byteorder easily. This could also be submitted separately, if you want.

I think the majority of places byteorder was used were more than well covered by the new from/to_le/be_bytes methods on integers. A few places where we're actually using it to read/write to byte slices needed more changes, mainly using copy_from_slice or try_into to convert &[u8] to [u8; N].

Let me know how this looks?

Fixes #24. CC #122.

@daboross daboross force-pushed the remove-byteorder branch 2 times, most recently from 7aab587 to 6e3f0ef Compare July 10, 2020 02:28
Copy link
Owner

@jonas-schievink jonas-schievink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks cleaner than before too, great! Can you rebase onto master so the RTIC rename gets in (to fix CI)?

This implements FromBytes and ToBytes for the remaining Header type
without these impls, and changes one place where we were writing the
Header to a ByteWriter to uses to_bytes rather than to_u16 +
LittleEndian::write_u16.

Closes jonas-schievink#24.

Signed-off-by: David Ross <[email protected]>
@daboross
Copy link
Contributor Author

Sounds good! Rebased.

There are a few places this ends up more verbose, but it removes a
dependency & source of unsafe code. The new-ish std methods cover
almost everything we were using byteorder for, in any case.

Signed-off-by: David Ross <[email protected]>
@jonas-schievink jonas-schievink merged commit 66b65ed into jonas-schievink:master Jul 10, 2020
@daboross daboross deleted the remove-byteorder branch July 10, 2020 20:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement ToBytes and FromBytes for Header types
2 participants