Struct ethrecv::RecvThread
source · 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)
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
fn main() {
let args: Vec<String> = env::args().skip(1).collect();
let rt = RecvThread::new(&args[0]);
#[cfg(feature = "idle")]
let rt = rt.idle_duration(std::time::Duration::from_secs(4));
let pp = PktProc::default();
#[cfg(feature = "inspect")]
let mut ctrl = rt.run(pp).unwrap();
#[cfg(not(feature = "inspect"))]
let ctrl = rt.run(pp).unwrap();
std::thread::sleep(std::time::Duration::from_secs(10));
#[cfg(feature = "inspect")]
ctrl.signal_inspect().unwrap();
#[cfg(feature = "inspect")]
{
let stats = ctrl.inspect().unwrap();
println!("{stats:#?}");
}
std::thread::sleep(std::time::Duration::from_secs(30));
#[cfg(feature = "inspect")]
{
let stats = ctrl.inspect().unwrap();
println!("{stats:#?}");
}
println!("Killing receiver thread..");
ctrl.shutdown().unwrap();
}
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)
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
fn main() {
let args: Vec<String> = env::args().skip(1).collect();
let rt = RecvThread::new(&args[0]);
#[cfg(feature = "idle")]
let rt = rt.idle_duration(std::time::Duration::from_secs(4));
let pp = PktProc::default();
#[cfg(feature = "inspect")]
let mut ctrl = rt.run(pp).unwrap();
#[cfg(not(feature = "inspect"))]
let ctrl = rt.run(pp).unwrap();
std::thread::sleep(std::time::Duration::from_secs(10));
#[cfg(feature = "inspect")]
ctrl.signal_inspect().unwrap();
#[cfg(feature = "inspect")]
{
let stats = ctrl.inspect().unwrap();
println!("{stats:#?}");
}
std::thread::sleep(std::time::Duration::from_secs(30));
#[cfg(feature = "inspect")]
{
let stats = ctrl.inspect().unwrap();
println!("{stats:#?}");
}
println!("Killing receiver thread..");
ctrl.shutdown().unwrap();
}
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)
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
fn main() {
let args: Vec<String> = env::args().skip(1).collect();
let rt = RecvThread::new(&args[0]);
#[cfg(feature = "idle")]
let rt = rt.idle_duration(std::time::Duration::from_secs(4));
let pp = PktProc::default();
#[cfg(feature = "inspect")]
let mut ctrl = rt.run(pp).unwrap();
#[cfg(not(feature = "inspect"))]
let ctrl = rt.run(pp).unwrap();
std::thread::sleep(std::time::Duration::from_secs(10));
#[cfg(feature = "inspect")]
ctrl.signal_inspect().unwrap();
#[cfg(feature = "inspect")]
{
let stats = ctrl.inspect().unwrap();
println!("{stats:#?}");
}
std::thread::sleep(std::time::Duration::from_secs(30));
#[cfg(feature = "inspect")]
{
let stats = ctrl.inspect().unwrap();
println!("{stats:#?}");
}
println!("Killing receiver thread..");
ctrl.shutdown().unwrap();
}
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