uutils / coreutils

Cross-platform Rust rewrite of the GNU coreutils
https://uutils.github.io/
MIT License
17.67k stars 1.27k forks source link

Multi-call `hashsum` binary is no longer necessary #4414

Open tertsdiepraam opened 1 year ago

tertsdiepraam commented 1 year ago

After https://github.com/uutils/coreutils/pull/4356, the combined hashsum binary will no longer be necessary. Still, all the hashing utilities will be based on hashsum, so my suggestion is to refactor the hashsum crate so that it defines multiple binaries, each with their own main function. We can then remove the multi-call logic and simplify the code, because the Digest type for each binary will be statically defined.

tertsdiepraam commented 1 year ago

I have changed my mind a bit. hashsum is still unnecessary and we need to remove it. cksum will first need to get feature parity and then we can start changing things up.

So here's my plan:

  1. Update cksum a bit to become a bit of a better version of the current hashsum.
  2. I want to extract the uucore::sum module to a crate multisum. The idea of this crate is to provide a common interface to many summing algorithms, which might be helpful for other projects too.
  3. Create a module for the common functionality based on the updated cksum in a subdirectory of uu.
  4. In that same subdirectory, we define all utils.

So something like this:

uu/
-- cksum/
   -- Cargo.toml
   -- src/
      -- common.rs
      -- b2sum.rs
      -- cksum.rs
      -- sum.rs
      -- etc.

I'm not sure that this exact structure will work, but I think it's gotta be something close to this.