use crate::bloom_sol::struct_def::CountingBloomFilter;
impl CountingBloomFilter {
/// Serializes the `CountingBloomFilter` instance into a `Vec<u8>`.
///
/// The serialization format is:
/// - 1 byte for `boolean_counting` (0 for false, 1 for true).
/// - 8 bytes for `size` (as little-endian u64).
/// - 8 bytes for `num_hashes` (as little-endian u64).
/// - 8 bytes for the length of `counters` (as little-endian u64).
/// - The raw bytes of `counters`.
pub fn serialize(&self) -> Vec<u8> {
let mut buf = Vec::new();
buf.push(if self.boolean_counting { 1 } else { 0 });
buf.extend_from_slice(&(self.size as u64).to_le_bytes());
buf.extend_from_slice(&(self.num_hashes as u64).to_le_bytes());
buf.extend_from_slice(&(self.counters.len() as u64).to_le_bytes());
buf.extend_from_slice(&self.counters);
buf
}
}