From a5390bb77766723520ffd37bbf0d9f0a7ab84552 Mon Sep 17 00:00:00 2001 From: Bitcoin Eagle Date: Wed, 23 Aug 2023 13:50:01 +0800 Subject: [PATCH] #8 implement serde feature --- fastbloom-rs/Cargo.toml | 6 +++++- fastbloom-rs/src/bloom.rs | 1 + fastbloom-rs/src/builder.rs | 1 + fastbloom-rs/src/vec.rs | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fastbloom-rs/Cargo.toml b/fastbloom-rs/Cargo.toml index 789d5de..2c7ff5c 100644 --- a/fastbloom-rs/Cargo.toml +++ b/fastbloom-rs/Cargo.toml @@ -19,4 +19,8 @@ license = "Apache-2.0" fastmurmur3 = "0.1.2" cuckoofilter = "0.5.0" xorfilter-rs = "0.5.1" -xxhash-rust = { version = "0.8", features = ["xxh3", "const_xxh3"] } \ No newline at end of file +xxhash-rust = { version = "0.8", features = ["xxh3", "const_xxh3"] } +serde = { version = "1.0.185", features = ["derive"], optional = true } + +[features] +serde = ["dep:serde"] diff --git a/fastbloom-rs/src/bloom.rs b/fastbloom-rs/src/bloom.rs index dc713b5..a03f475 100644 --- a/fastbloom-rs/src/bloom.rs +++ b/fastbloom-rs/src/bloom.rs @@ -84,6 +84,7 @@ fn get_bit_indices(bit_set: &BloomBitVec, value: &[u8], m: u64, k: u64) -> Vec usize { /// bitmap only for bloom filter. #[derive(Debug)] #[derive(Clone)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub(crate) struct BloomBitVec { /// Internal representation of the bit vector pub(crate) storage: Vec,