use { crate::{Error, Node}, std::{ io::{ErrorKind, Read}, iter::Iterator, }, }; #[derive(Debug)] pub struct Stream { reader: T, } impl From for Stream { fn from(value: T) -> Self { Self { reader: value } } } impl Iterator for Stream { type Item = Result; fn next(&mut self) -> Option { match Node::read(&mut self.reader) { Err(Error::Io(e)) if e.kind() == ErrorKind::UnexpectedEof => None, x => Some(x), } } }