pub struct PushEventReceiver(pub Receiver<Event>);Expand description
Receiver end of the device-sent event queue.
Owner of the receiver can regularly attempt to pop events from the queue, and decide how to handle any returned event(s).
Example:
let stop_polling = Arc::new(AtomicBool::new(false));
let poll_mode = ssp_server::PollMode::Interactive;
let mut handle = ssp_server::DeviceHandle::new("/dev/ttyUSB0")?;
let rx: ssp_server::PushEventReceiver = handle.start_background_polling_with_queue(
Arc::clone(&stop_polling),
poll_mode,
)?;
// Pop events from the queue
loop {
while let Ok(event) = rx.pop_event() {
log::debug!("Received an event: {event}");
// do stuff in response to the event...
}
}Tuple Fields§
§0: Receiver<Event>Implementations§
Auto Trait Implementations§
impl Freeze for PushEventReceiver
impl RefUnwindSafe for PushEventReceiver
impl Send for PushEventReceiver
impl Sync for PushEventReceiver
impl Unpin for PushEventReceiver
impl UnwindSafe for PushEventReceiver
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