pub fn read(file:&mut dyn Read) -> Result<Vec<Chunk>, ReadError> {
	let mut magic:[u8;8] = [0,0,0,0,0,0,0,0];
	file.read_exact(&mut magic).map_err(ReadError::Io).and_then(|_| {
		let magic = magic;
		if magic == MAGIC {
			let mut retval:Vec<Chunk> = Vec::new();

			loop {
				match Chunk::read(file) {
					Result::Ok(Some(x)) => {
						retval.push(x);
					},
					Result::Ok(None) => {
						break Ok(retval);
					}
					Result::Err(x) => {
						break Err(ReadError::from(x));
					},
				}
			}
		} else {
			Err(ReadError::MagicMismatch(magic))
		}
	})
}
/// Reads a png file, and returns the chunks contained in that file
Reads a png file, and returns the chunks contained in that file
Reads a png file and returns the chunks contained in that file
pub fn read(file:&mut dyn Read) -> Result<Vec<Chunk>, ReadError> {
	let mut magic:[u8;8] = [0,0,0,0,0,0,0,0];
	file.read_exact(&mut magic).map_err(ReadError::Io).and_then(|_| {
		let magic = magic;
		if magic == MAGIC {
			let mut retval:Vec<Chunk> = Vec::new();
			loop {
				match Chunk::read(file) {
					Result::Ok(Some(x)) => {
						retval.push(x);
					},
					Result::Ok(None) => {
						break Ok(retval);
					}
					Result::Err(x) => {
						break Err(ReadError::from(x));
					},
				}
			}
		} else {
			Err(ReadError::MagicMismatch(magic))
		}
	})
}
pub fn read ( file : & mut dyn Read ) -> Result < Vec < Chunk > , ReadError > { let mut magic : [ u8 ; 8 ] = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ; file . read_exact ( & mut magic ) . map_err ( ReadError :: Io ) . and_then ( | _ | { let magic = magic ; if magic == MAGIC { let mut retval : Vec < Chunk > = Vec :: new ( ) ; loop { match Chunk :: read ( file ) { Result :: Ok ( Some ( x ) ) => { retval . push ( x ) ; } , Result :: Ok ( None ) => { break Ok ( retval ) ; } Result :: Err ( x ) => { break Err ( ReadError :: from ( x ) ) ; } , } } } else { Err ( ReadError :: MagicMismatch ( magic ) ) } } ) }
Reads a png file, and returns the chunks contained in that file
Reads a png file and returns the chunks contained in that file
file
&mut dyn Read