MCPcopy Create free account
hub / github.com/emberian/evdev / poll_event

Method poll_event

src/uinput.rs:610–633  ·  view source on GitHub ↗

A lower-level function for directly polling this stream.

(&mut self, cx: &mut Context<'_>)

Source from the content-addressed store, hash-verified

608
609 /// A lower-level function for directly polling this stream.
610 pub fn poll_event(&mut self, cx: &mut Context<'_>) -> Poll<io::Result<InputEvent>> {
611 'outer: loop {
612 if let Some(&ev) = self.device.get_ref().event_buf.get(self.index) {
613 self.index += 1;
614 return Poll::Ready(Ok(InputEvent::from(ev)));
615 }
616
617 self.device.get_mut().event_buf.clear();
618 self.index = 0;
619
620 loop {
621 let mut guard = ready!(self.device.poll_read_ready_mut(cx))?;
622
623 let res = guard.try_io(|device| device.get_mut().fill_events());
624 match res {
625 Ok(res) => {
626 let _ = res?;
627 continue 'outer;
628 }
629 Err(_would_block) => continue,
630 }
631 }
632 }
633 }
634 }
635
636 #[cfg(feature = "stream-trait")]

Callers 2

next_eventMethod · 0.45
poll_nextMethod · 0.45

Calls 1

fill_eventsMethod · 0.45

Tested by

no test coverage detected