feat: add blake3 command#3658
Merged
Merged
Conversation
Add a new `blake3` command that computes BLAKE3 cryptographic hashes of files, functionally similar to b3sum. Supports keyed hashing, key derivation, variable-length output, checksum verification, tagged output, and stdin input. Uses mmap+rayon for maximum throughput. Also fixes the command name lowercase check to allow digits, since `'3'.is_lowercase()` returns false. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…s for --raw/--keyed/stdin Address review findings: - Merge `use crate::CliError` into the main import block - Validate hex checksum strings (even length, hex chars only) before comparison - Add tests for --raw, --keyed, stdin (-), --output, --num-threads, and invalid hex Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
wrk.stdout() already runs the command and panics on failure, so the subsequent wrk.assert_success() just re-executes the command for no benefit. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use the same -j/--jobs flag name as other qsv commands (snappy, stats, etc.) and delegate to util::njobs() instead of manual rayon pool setup. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 90 |
TIP This summary will be updated as you push new changes. Give us feedback
…tive Update tests/test_blake3.rs to use cmd_2 instead of cmd2 in two test functions and adjust argument chaining for readability. Standardizes the local command variable name and cleans up minor formatting.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new qsv blake3 subcommand to compute and verify BLAKE3 hashes for files/stdin, along with documentation and an integration test suite.
Changes:
- Introduces
blake3command implementation with hashing modes (default/keyed/derive-key), output formats, and checksum verification. - Registers the new command in the CLI dispatcher and command/module listings.
- Adds help docs + README/TableOfContents entries and a comprehensive
tests/test_blake3.rsintegration test file.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/tests.rs | Registers the new test_blake3 integration test module. |
| tests/test_blake3.rs | Adds end-to-end tests for hashing, verification, stdin, raw output, and options. |
| src/main.rs | Wires blake3 into the command list, enum, dispatcher, and relaxes command-name validation to allow digits. |
| src/cmd/mod.rs | Exposes the new cmd::blake3 module. |
| src/cmd/blake3.rs | Implements the qsv blake3 command (hashing + check mode + output formatting). |
| README.md | Adds blake3 to the command list in the README. |
| docs/help/TableOfContents.md | Adds blake3 to the help Table of Contents. |
| docs/help/blake3.md | Adds generated help documentation for blake3. |
…d, error messages
- Reject `-` in --keyed mode since stdin is consumed for the key
- Stream stdin incrementally (8KiB chunks) instead of read_to_end
- Stream --no-mmap file reads via BufReader instead of fs::read
- Remove Path::exists() pre-check, rely on actual I/O errors
- Replace fail!("") with fail_clierror! for meaningful error on check failure
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Read directly from File with 8KiB buffer instead of wrapping in BufReader, which was adding a redundant intermediate buffer. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add feature gate `#[cfg(any(feature = "feature_capable", feature = "datapusher_plus"))]` to exclude blake3 from the qsvlite binary variant. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace manual 8KiB read loops with blake3's update_reader() for both stdin and --no-mmap file paths - Use finalize().to_hex() for default 32-byte output (stack-allocated Hash + ArrayString, no heap allocation) instead of finalize_xof() + OutputReader clone + Vec + manual hex loop - Return Hasher from hash_input instead of OutputReader, letting caller choose finalization strategy - Remove finalize_to_bytes helper, inline the xof path Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ustom length paths Extract hex string computation into a single conditional, then share one formatting block for no_names/tag/default output modes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Register a new 'blake3' command in the CLI: add it to the command list, introduce a Command::Blake3 enum variant, and dispatch to cmd::blake3::run(argv) in the main match. Also relax the command-name validation to accept ASCII digits in addition to lowercase letters so commands containing numbers are allowed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
For computing and checking BLAKE3 hashes of files.
Used primarily for:
b3sumCLI