-
Notifications
You must be signed in to change notification settings - Fork 72
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
feat(crc): add crc hash fn #1136
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @ivor11. This looks good. We will need a PR on Vector to document this new function.
src/stdlib/crc32.rs
Outdated
fn parameters(&self) -> &'static [Parameter] { | ||
&[Parameter { | ||
keyword: "value", | ||
kind: kind::ANY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm I noticed this in other hash function. I don't think ANY
is ideal but we can leave it here for consistency.
Awesome @pront. I have created a PR on vector to document this function |
src/stdlib/crc32.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many kinds of CRC functions, even many kinds of 32-bit CRC functions. Instead of adding a separate function for each, would it make sense to instead have a single crc
function with some "algorithm" parameter like decrypt
, encrypt
, and hmac
use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. @ivor11 should be trivial to modify this PR to do the above. Let me know if this makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks. I will take a look at the updated code.
use crate::value; | ||
use crc::Crc as CrcInstance; | ||
|
||
fn crc(value: Value, algorithm: Value) -> Resolved { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 This is one of those (rare) cases where a #[proc_macro]
can significantly reduce the boilerplate. We could iterate over valid_algorithms
and keep pushing:
$algo => CrcInstance::<u8>::new(&crc::$algo)
.checksum(&value)
.to_string(),
But this is just my observation. Feel free to ignore this comment.
This also need a changelog to communicate this new feature to the users. |
@pront my bad, I've added the changelog file. Thanks for the thorough review |
Summary
Add crc hash fn with an algorithm parameter
default algorithm used - CRC_32_ISO_HDLC
Change Type
Is this a breaking change?
How did you test this PR?
Does this PR include user facing changes?
our guidelines.
Checklist
run
dd-rust-license-tool write
and commit the changes. More details here.References
#997