jedisct1 / rust-bloom-filter

A fast Bloom filter implementation in Rust
BSD 2-Clause "Simplified" License
235 stars 51 forks source link

added serde derive, feature flag and test #19

Closed gh0st42 closed 3 years ago

gh0st42 commented 4 years ago

Bloom filters can now be serialized to whatever has a serde implementation. A test to verify the serializing and deserializing process is also added but currently only executed if the feature flag for "serde" is set. Cargo.toml now contains a not yet valid new minor version of siphash (https://github.com/jedisct1/rust-siphash/pull/12) This might need tweaking if you want to increase the major number.

I did not add the feature to the default feature list. To use serde one has to specify features = ["serde"]. It might be better to include this in the default list...

Finally, I added #![forbid(unsafe_code)] to the top of lib.rs as no unsafe code is needed here and it gives a fancy super secure symbol in cargo-geiger ;)

gh0st42 commented 4 years ago

Updated to have correct SipHash version number with serde support and changed unit test to not rely on assert_eq and therefore PartialEq.

Test can be triggered as follow:

$ cargo test --features "serde"

running 5 tests
test bloom_test_set ... ok
test bloom_test_clear ... ok
test bloom_test_check_and_set ... ok
test bloom_test_load ... ok
test bloom_test_serde ... ok

test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests bloomfilter

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
zonyitoo commented 3 years ago

@jedisct1 What do you think about his PR?