Figure out what to do about digests
- Dominant language
- Rust
- Stars
- 70
- Forks
- 34
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 25
Description
Currently in a lot of places in the codebase we use types like `[u8; 32]` to represent hash digests. These work but this does not feel super-idiomatic and type safety could be improved.
Generally, we use the [`digest`] crate and its derivatives (e.g. [`sha2`]) for hash calculation. Unfortunately, the crate is [very][1], [very][2] abstracted and does not expose any "simple" hash type for output of each algorithm that we could use. Moreover, because everything works on traits, each time we need to use it, we need appropriate traits into scope which does not help with the noise.
Ideally, we should define our own new-type wrappers for each digest algorithm with an interface that best fits our (simple) use-cases. We should do it uniformly across all our internal usages at once to prevent [xkcd#927][3] situation, preferably even totally hiding our reliance on `digest`.
An extra layer of complexity in this case is that the `get_file_metadata` action has [conditional features][4] for each digest algorithm dependency. For this to work, we will likely need an extra feature for each on top of that.
[`digest`]: https://crates.io/crates/digest
[`sha2`]: https://crates.io/crates/sha2
[1]: https://docs.rs/digest/0.10.7/digest/type.Output.html
[2]: https://docs.rs/sha2/latest/sha2/type.Sha256.html
[3]: https://xkcd.com/927/
[4]: https://github.com/google/rrg/blob/4c2dafe13dc96ecec26f873db5d954f47a9cf1ad/crates/rrg/Cargo.toml#L35-L37
Contributor guide
Assessment
This issue has not been assessed yet.