Skip to content

Commit

Permalink
feat(crc): add crc hash fn (#1136)
Browse files Browse the repository at this point in the history
* feat(crc32): add crc32 hash fn

* add algorithm param to crc function

* update bench_function for crc

* remove base64 encode from example crc usage

* add invalid test case, code formatting

* add changelog
  • Loading branch information
ivor11 authored Dec 21, 2024
1 parent acae0e7 commit 8590030
Show file tree
Hide file tree
Showing 7 changed files with 626 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ stdlib = [
"dep:convert_case",
"dep:cidr-utils",
"dep:community-id",
"dep:crc",
"dep:crypto_secretbox",
"dep:csv",
"dep:ctr",
Expand Down Expand Up @@ -135,6 +136,7 @@ csv = { version = "1", optional = true }
clap = { version = "4", features = ["derive"], optional = true }
codespan-reporting = { version = "0.11", optional = true }
convert_case = { version = "0.6.0", optional = true }
crc = { version = "3.2.1", optional = true }
data-encoding = { version = "2", optional = true }
digest = { version = "0.10", optional = true }
dyn-clone = { version = "1", default-features = false, optional = true }
Expand Down
2 changes: 2 additions & 0 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ convert_case,https://github.com/rutrum/convert-case,MIT,David Purdum <purdum41@g
convert_case,https://github.com/rutrum/convert-case,MIT,Rutrum <dave@rutrum.net>
core-foundation,https://github.com/servo/core-foundation-rs,MIT OR Apache-2.0,The Servo Project Developers
cpufeatures,https://github.com/RustCrypto/utils,MIT OR Apache-2.0,RustCrypto Developers
crc,https://github.com/mrhooray/crc-rs,MIT OR Apache-2.0,"Rui Hu <code@mrhooray.com>, Akhil Velagapudi <4@4khil.com>"
crc-catalog,https://github.com/akhilles/crc-catalog,MIT OR Apache-2.0,Akhil Velagapudi <akhilvelagapudi@gmail.com>
crc32fast,https://github.com/srijs/rust-crc32fast,MIT OR Apache-2.0,"Sam Rijs <srijs@airpost.net>, Alex Crichton <alex@alexcrichton.com>"
crossbeam-channel,https://github.com/crossbeam-rs/crossbeam,MIT OR Apache-2.0,The crossbeam-channel Authors
crossbeam-epoch,https://github.com/crossbeam-rs/crossbeam,MIT OR Apache-2.0,The crossbeam-epoch Authors
Expand Down
10 changes: 10 additions & 0 deletions benches/stdlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ criterion_group!(
community_id,
compact,
contains,
crc,
decode_base16,
decode_base64,
decode_charset,
Expand Down Expand Up @@ -290,6 +291,15 @@ bench_function! {
}
}

bench_function! {
crc => vrl::stdlib::Crc;

literal {
args: func_args![value: "foo"],
want: Ok(b"2356372769"),
}
}

bench_function! {
decode_base16 => vrl::stdlib::DecodeBase16;

Expand Down
3 changes: 3 additions & 0 deletions changelog.d/1136.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Added new `crc` function to calculate CRC (Cyclic Redundancy Check) checksum

authors: ivor11
Loading

0 comments on commit 8590030

Please sign in to comment.