1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
use std; #[derive(Clone, Debug)] pub struct Config { max_packets_read: usize, snaplen: u32, timeout: std::time::Duration, buffer_size: u32, bpf: Option<String>, retry_after: std::time::Duration, } impl Config { pub fn max_packets_read(&self) -> usize { self.max_packets_read } pub fn with_max_packets_read(&mut self, amt: usize) -> &mut Self { self.max_packets_read = amt; self } pub fn snaplen(&self) -> u32 { self.snaplen } pub fn with_snaplen(&mut self, amt: u32) -> &mut Self { self.snaplen = amt; self } pub fn timeout(&self) -> &std::time::Duration { &self.timeout } pub fn with_timeout(&mut self, amt: std::time::Duration) -> &mut Self { self.timeout = amt; self } pub fn buffer_size(&self) -> u32 { self.buffer_size } pub fn with_buffer_size(&mut self, amt: u32) -> &mut Self { self.buffer_size = amt; self } pub fn bpf(&self) -> &Option<String> { &self.bpf } pub fn with_bpf(&mut self, amt: String) -> &mut Self { self.bpf = Some(amt); self } pub fn retry_after(&self) -> &std::time::Duration { &self.retry_after } pub fn with_retry_after(&mut self, amt: std::time::Duration) -> &mut Self { self.retry_after = amt; self } pub fn new( max_packets_read: usize, snaplen: u32, timeout: std::time::Duration, buffer_size: u32, bpf: Option<String>, retry_after: std::time::Duration, ) -> Config { Config { max_packets_read, snaplen, timeout, buffer_size, bpf, retry_after, } } } impl Default for Config { fn default() -> Config { Config { max_packets_read: 1000, snaplen: 65535, timeout: std::time::Duration::from_millis(100), buffer_size: 16777216, bpf: None, retry_after: std::time::Duration::from_millis(100), } } }