My Stream::poll_next implementation

Please review this implementation of Stream:

impl Stream for Input {
	type Item = std::io::Result<Event>;

	#[inline]
	fn poll_next(
		mut self: Pin<&mut Self>,
		cx: &mut Context<'_>,
	) -> Poll<Option<std::io::Result<Event>>> {
		let this = &mut *self;
		let devices = &mut this.devices;
		let state = &mut this.state;

		if let Some(prev_event) = state.out_queue.pop_front() {
			return Poll::Ready(Some(Ok(prev_event)));
		}

		if let Poll::Ready(Some(event)) = Pin::new(&mut devices.inotify).poll_next(cx) {
			match (|| {
				let event = event?;

				let Some(name) = event.name else {
					return Ok(None);
				};

				let path = Path::new(INPUT_DIR).join(name);

				tracing::debug!(?path, "new input device");
				let device = Device::open(&path)?;
				devices.autodetect_device(&path, device)
			})() {
				Ok(Some(connected_type)) => {
					return Poll::Ready(Some(Ok(Event::DevicePresence(connected_type))));
				}
				Ok(None) => {}
				Err(error) => return Poll::Ready(Some(Err(error))),
			}
		}

		'each: for _ in 0..devices.devices.len() {
			let i = usize::from(devices.last_polled_device);
			devices.last_polled_device = devices.last_polled_device.wrapping_add(1)
				% u8::try_from(SupportedDeviceType::ALL.len()).unwrap();

			let type_ = SupportedDeviceType::ALL[i];
			let mut slot = &mut devices.devices[i];
			if let Some(device) = &mut slot {
				let handler = match type_ {
					SupportedDeviceType::Keyboard | SupportedDeviceType::Buttons => handle_keyboard,
					SupportedDeviceType::Touchscreen => handle_touchscreen,
					SupportedDeviceType::Stylus => handle_stylus,
				};

				let events = device.poll_event(cx);
				let events = events.map(|res| {
					res.map(|events| {
						handler(events, state);
					})
				});
				match events {
					Poll::Ready(res) => {
						match res {
							Ok(()) => {
								break 'each;
							}
							Err(error) => match error.raw_os_error() {
								// `errno` for "No such device". The device was disconnected.
								Some(19) => {
									*slot = None;
									state.enqueue(Event::DevicePresence(type_));
									continue;
								}
								_ => {
									return Poll::Ready(Some(Err(error)));
								}
							},
						}
					}
					Poll::Pending => continue,
				}
			}
		}

		if let Some(prev_event) = state.out_queue.pop_front() {
			Poll::Ready(Some(Ok(prev_event)))
		} else {
			Poll::Pending
		}
	}
}

self.devices.inotify is inotify::EventStream, self.devices.devices is an array of Option<EventStream>, self.state.out_queue is VecDeque<Event> (self.state.enqueue just push_backs into this queue).

Especially I am wondering about the last_polled_device mechanism which is intended to provide fairness of polling each device. I got this from tokio-stream's StreamMap.