#bloom-filter #input #vapory #tetsy #literals #hex

no-std vapbloom

Tetsy Common Vapory Bloom Filter

Show the crate…

4 releases (2 breaking)

0.11.1 Jun 8, 2021
0.11.0 Feb 18, 2021
0.10.0 Mar 10, 2021
0.8.0 Feb 20, 2021

#9 in #vapory

Download history 101/week @ 2024-11-13 117/week @ 2024-11-20 139/week @ 2024-11-27 164/week @ 2024-12-04 221/week @ 2024-12-11 111/week @ 2024-12-18 13/week @ 2024-12-25 82/week @ 2025-01-01 54/week @ 2025-01-08 100/week @ 2025-01-15 91/week @ 2025-01-22 77/week @ 2025-01-29 83/week @ 2025-02-05 97/week @ 2025-02-12 49/week @ 2025-02-19 74/week @ 2025-02-26

316 downloads per month
Used in 70 crates (3 directly)

MIT/Apache

65KB
1K SLoC

use hex_literal::hex;
use vapbloom::{Bloom, Input};

use std::str::FromStr;
let bloom = Bloom::from_str(
	"00000000000000000000000000000000\
	00000000100000000000000000000000\
	00000000000000000000000000000000\
	00000000000000000000000000000000\
	00000000000000000000000000000000\
	00000000000000000000000000000000\
	00000002020000000000000000000000\
	00000000000000000000000800000000\
	10000000000000000000000000000000\
	00000000000000000000001000000000\
	00000000000000000000000000000000\
	00000000000000000000000000000000\
	00000000000000000000000000000000\
	00000000000000000000000000000000\
	00000000000000000000000000000000\
	00000000000000000000000000000000"
).unwrap();
let address = hex!("ef2d6d194084c2de36e0dabfce45d046b37d1106");
let topic = hex!("02c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc");

let mut my_bloom = Bloom::default();
assert!(!my_bloom.contains_input(Input::Raw(&address)));
assert!(!my_bloom.contains_input(Input::Raw(&topic)));

my_bloom.accrue(Input::Raw(&address));
assert!(my_bloom.contains_input(Input::Raw(&address)));
assert!(!my_bloom.contains_input(Input::Raw(&topic)));

my_bloom.accrue(Input::Raw(&topic));
assert!(my_bloom.contains_input(Input::Raw(&address)));
assert!(my_bloom.contains_input(Input::Raw(&topic)));
assert_eq!(my_bloom, bloom);

Dependencies

~89–680KB
~12K SLoC