pcap_async/bpf.rs
1/// Wrapper for bpf_program to ensure correct drops
2#[derive(Debug)]
3pub struct Bpf {
4 inner: pcap_sys::bpf_program,
5}
6
7impl Bpf {
8 pub fn new(inner: pcap_sys::bpf_program) -> Bpf {
9 Bpf { inner }
10 }
11 pub fn inner_mut(&mut self) -> &mut pcap_sys::bpf_program {
12 &mut self.inner
13 }
14}
15
16impl Drop for Bpf {
17 fn drop(&mut self) {
18 unsafe {
19 pcap_sys::pcap_freecode(&mut self.inner);
20 }
21 }
22}