pub struct RecvThread { /* private fields */ }Expand description
A builder-like object for initializing the packet receiver thread.
Implementations§
Source§impl RecvThread
impl RecvThread
Sourcepub fn new(devname: &str) -> Self
pub fn new(devname: &str) -> Self
Examples found in repository?
examples/simple-demo.rs (line 39)
36fn main() {
37 let args: Vec<String> = env::args().skip(1).collect();
38
39 let rt = RecvThread::new(&args[0]);
40
41 #[cfg(feature = "idle")]
42 let rt = rt.idle_duration(std::time::Duration::from_secs(4));
43
44 let pp = PktProc::default();
45
46 #[cfg(feature = "inspect")]
47 let mut ctrl = rt.run(pp).unwrap();
48
49 #[cfg(not(feature = "inspect"))]
50 let ctrl = rt.run(pp).unwrap();
51
52 std::thread::sleep(std::time::Duration::from_secs(10));
53
54 #[cfg(feature = "inspect")]
55 ctrl.signal_inspect().unwrap();
56
57 #[cfg(feature = "inspect")]
58 {
59 let stats = ctrl.inspect().unwrap();
60 println!("{stats:#?}");
61 }
62
63 std::thread::sleep(std::time::Duration::from_secs(30));
64
65 #[cfg(feature = "inspect")]
66 {
67 let stats = ctrl.inspect().unwrap();
68 println!("{stats:#?}");
69 }
70
71 println!("Killing receiver thread..");
72
73 ctrl.shutdown().unwrap();
74}pub fn bufsize<E>(self, bufsize: usize) -> Result<Self, Error<E>>
pub fn bufsize_r<E>(&mut self, bufsize: usize) -> Result<&mut Self, Error<E>>
Sourcepub fn idle_duration(self, dur: Duration) -> Self
Available on crate feature idle only.
pub fn idle_duration(self, dur: Duration) -> Self
idle only.Examples found in repository?
examples/simple-demo.rs (line 42)
36fn main() {
37 let args: Vec<String> = env::args().skip(1).collect();
38
39 let rt = RecvThread::new(&args[0]);
40
41 #[cfg(feature = "idle")]
42 let rt = rt.idle_duration(std::time::Duration::from_secs(4));
43
44 let pp = PktProc::default();
45
46 #[cfg(feature = "inspect")]
47 let mut ctrl = rt.run(pp).unwrap();
48
49 #[cfg(not(feature = "inspect"))]
50 let ctrl = rt.run(pp).unwrap();
51
52 std::thread::sleep(std::time::Duration::from_secs(10));
53
54 #[cfg(feature = "inspect")]
55 ctrl.signal_inspect().unwrap();
56
57 #[cfg(feature = "inspect")]
58 {
59 let stats = ctrl.inspect().unwrap();
60 println!("{stats:#?}");
61 }
62
63 std::thread::sleep(std::time::Duration::from_secs(30));
64
65 #[cfg(feature = "inspect")]
66 {
67 let stats = ctrl.inspect().unwrap();
68 println!("{stats:#?}");
69 }
70
71 println!("Killing receiver thread..");
72
73 ctrl.shutdown().unwrap();
74}pub fn idle_duration_r(&mut self, dur: Duration) -> &mut Self
Available on crate feature
idle only.Source§impl RecvThread
impl RecvThread
Sourcepub fn run<E>(
self,
handler: impl PacketHandler<Error = E> + Send + 'static,
) -> Result<Controller<E>, Error<E>>where
E: Send + 'static,
pub fn run<E>(
self,
handler: impl PacketHandler<Error = E> + Send + 'static,
) -> Result<Controller<E>, Error<E>>where
E: Send + 'static,
Examples found in repository?
examples/simple-demo.rs (line 47)
36fn main() {
37 let args: Vec<String> = env::args().skip(1).collect();
38
39 let rt = RecvThread::new(&args[0]);
40
41 #[cfg(feature = "idle")]
42 let rt = rt.idle_duration(std::time::Duration::from_secs(4));
43
44 let pp = PktProc::default();
45
46 #[cfg(feature = "inspect")]
47 let mut ctrl = rt.run(pp).unwrap();
48
49 #[cfg(not(feature = "inspect"))]
50 let ctrl = rt.run(pp).unwrap();
51
52 std::thread::sleep(std::time::Duration::from_secs(10));
53
54 #[cfg(feature = "inspect")]
55 ctrl.signal_inspect().unwrap();
56
57 #[cfg(feature = "inspect")]
58 {
59 let stats = ctrl.inspect().unwrap();
60 println!("{stats:#?}");
61 }
62
63 std::thread::sleep(std::time::Duration::from_secs(30));
64
65 #[cfg(feature = "inspect")]
66 {
67 let stats = ctrl.inspect().unwrap();
68 println!("{stats:#?}");
69 }
70
71 println!("Killing receiver thread..");
72
73 ctrl.shutdown().unwrap();
74}Auto Trait Implementations§
impl Freeze for RecvThread
impl RefUnwindSafe for RecvThread
impl Send for RecvThread
impl Sync for RecvThread
impl Unpin for RecvThread
impl UnwindSafe for RecvThread
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more