irox_tools/read/readerator.rs
1// SPDX-License-Identifier: MIT
2// Copyright 2023 IROX Contributors
3//
4
5///
6/// Super basic implementation of iterator for [`std::io::Read`]
7pub struct Readerator<T>(pub T);
8
9impl<T: std::io::Read> Iterator for Readerator<T> {
10 type Item = u8;
11
12 fn next(&mut self) -> Option<Self::Item> {
13 let mut buf: [u8; 1] = [0];
14 let Ok(val) = self.0.read(&mut buf) else {
15 return None;
16 };
17 if val != 1 {
18 return None;
19 }
20 Some(buf[0])
21 }
22}