Skip to content

Support custom crc parameters #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

onethumb
Copy link
Contributor

The Problem

While the list of hardcoded supported CRC variants is comprehensive, covering all the known CRC-32 and CRC-64 variants, it may be useful to support arbitrary custom parameters for future or unknown variants.

The Solution

Add support for custom CRC parameters.

Changes

  • Add functions to support Digest, checksum, and checksum_file operations using custom parameters.
  • Add test coverage.
  • Add support for the new functions in the C-compatible shared library as well.

Planned version bump

  • Which: MINOR
  • Why: non-breaking new functionality

Links

@onethumb onethumb requested a review from Copilot June 10, 2025 23:03
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces support for custom CRC parameters in the library and its C-compatible shared library. Key changes include:

  • Adding new functions (new_with_params, checksum_with_params, checksum_file_with_params) in Rust to support custom CRC parameters.
  • Extending FFI bindings in Rust and updating the C header (libcrc_fast.h) to expose the new API.
  • Adding test coverage for the new functionality.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/lib.rs New functions for custom CRC parameters added, along with corresponding tests.
src/ffi.rs FFI functions added to support the new custom parameter API.
libcrc_fast.h Updated header file exposing the new API for custom parameters.
Comments suppressed due to low confidence (1)

src/lib.rs:618

  • The variable 'digest' is declared but never used in this test. Consider removing it to avoid confusion.
let mut digest = Digest::new(config.get_algorithm());

onethumb added 7 commits June 11, 2025 11:09
- Crc32Custom and Crc64Custom CrcAlgorithms
- checksum_combine_with_custom_params() function
- get_custom_params() function
- test coverage for the above
Enables easier integration for consumers who would like to use custom
CRC parameters, such as polynomials.
- Adds the Crc32Custom and Crc64Custom CrcFastAlgorithms
- Adds the crc_fast_checksum_combine_with_custom_params() function
- Adds the crc_fast_get_custom_params() function
Replaces get_custom_params() with CrcParams::new().

awesomized#11 (comment)
Copy link

@jg15 jg15 left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for adding these changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants