To familiarize myself with Rust, I took it upon myself to write a bloom filter that is backed by a BitVec
. Part of that will include a save
method that serializes the whole struct using serde and writes it to a file. Unfortunately, I get a compiler error when deriving the Serialize
trait:
use bitvec::vec::BitVec;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
pub struct BloomFilter {
n: u64, // items added
m: u32, // slice size
k: u32, // number of slices
buf: BitVec, // buffer
state: [u8; 8], // random state
}
error[E0277]: the trait bound `BitVec: Serialize` is not satisfied
--> src/bloom.rs:12:10
|
12 | #[derive(Serialize, Deserialize)]
| ^^^^^^^^^ the trait `Serialize` is not implemented for `BitVec`
...
17 | buf: BitVec, // buffer
| --- required by a bound introduced by this call
My relevant Cargo.toml
dependencies:
[dependencies]
bitvec = "1.0.1"
serde = { version = "1.0.196", features = ["derive"] }
This seems odd to me, since the docs for bitvec 1.0.1 mention Serialize
(and Deserialize
) as one of the traits implemented. Am I making some obvious mistake here?