Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Remove byteorder dependency #390

Closed
wants to merge 11 commits into from
Closed

Conversation

psychon
Copy link

@psychon psychon commented Aug 18, 2023

Hi,

I came across the use of "byteorder" in this crate and thought "one does not really need byteorder for this". Feel free to disagree and to just close this PR.

Since there are many uses of "byteorder", I tried to do this in small parts and do a commit for each one. Hopefully this makes it easier to understand what is going on. Dunno.

Then I noticed that actions are failing in my fork. The last few commits make rustfmt and clippy happy. These changes are unrelated to this PR. Feel free to cherry pick what you want.

Note that CI will still fail, because:

error: package `base64ct v1.6.0` cannot be built because it requires rustc 1.60 or newer, while the currently active rustc version is 1.59.0

I'll leave that one to you.

Converting an u16 to bytes can easily be done with just the standard
library. This does not need the byteorder crate.

Signed-off-by: Uli Schlachter <[email protected]>
Reading u8, u16, u32, and u64 can easily be done with what the standard
library provides and does not need the byteorder crate.

Signed-off-by: Uli Schlachter <[email protected]>
Similar to the previous commit: What byteorder provides here can easily
be done with the standard library.

This moves the helper functions that were added in the previous commit
to "spec" (since "read" already imports "spec", but not the other way)
and converts the code to use these helpers instead of byteorder.

Signed-off-by: Uli Schlachter <[email protected]>
One really does not need the byteorder crate to write some bytes of
data. It can easily be done with methods from the std library.

Signed-off-by: Uli Schlachter <[email protected]>
This commit converts the reading code in the "write" module to use the
read_u16() helper function that was added in a previous commit.

Signed-off-by: Uli Schlachter <[email protected]>
We do not need the "byteorder" crate for writing little endian numbers
to a Write, but can do that just with methods from std.

Signed-off-by: Uli Schlachter <[email protected]>
The previous commits replaces the use of this crate and it is now unused
and can be removed.

Signed-off-by: Uli Schlachter <[email protected]>
I do not know where these differences come from. I didn't touch this
code. But CI is telling me to fix this.

Signed-off-by: Uli Schlachter <[email protected]>
The warning is "variable does not need to be mutable". But actually,
this whole variable is not needed and can just be inlined into its only
use.

Signed-off-by: Uli Schlachter <[email protected]>
The warnings include:

- roundtrip() takes a &mut, but only uses this argument non-mutably
- using std::mem::replace() to replace an Option with None (just use
  .take() instead)
- "manual backwards iteration", i.e. using rev().next() instead of
  next_back()

Signed-off-by: Uli Schlachter <[email protected]>
@Pr0methean
Copy link
Member

This repo is no longer maintained. Could you please rebase this change against https://github.com/zip-rs/zip2 and submit it there?

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.

2 participants