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, Ok(f) => match f.filetype { crate::FileType::Eof => None, _ => Some(Ok(f)), }, x => Some(x), } } } impl Stream { pub fn extract(&mut self, prefix: Option<&str>) -> Result<(), Error> { todo!() } #[cfg(feature = "parallel")] pub fn par_extract(&mut self, prefix: Option<&str>) -> Result<(), Error> { todo!() } }