A lower-level function for directly polling this stream.
(&mut self, cx: &mut Context<'_>)
| 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")] |
no test coverage detected