use { crate::{Error, Node}, std::{ io::{ErrorKind, Read}, iter::Iterator, }, }; /// An iterator over a series of archive `Node`'s. This struct is generic over any /// type which implements `Read`, such as a file or a network stream. #[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), } } }