use qoicodec::DecodeError; use qoicodec::try_read_magic; use std::{fs::File, io::Read}; fn main() { let file = File::open("qoi_test_images/dice.qoi").unwrap(); let mut bytes = file.bytes() .map(|maybe_bytes| { match maybe_bytes { Ok(byte) => byte, Err(oops) => panic!("Oops, the file failed to load: {}", oops) } }); if let Err(e) = try_read_magic(&mut bytes) { match e { DecodeError::Magic => panic!("QOI Magic bytes are bad!"), DecodeError::EarlyIteratorExhaustion => panic!("File iterator exhausted earlier than expected."), _ => panic!("Unhandled error reading magic: {:?}", e), } } todo!("The rest of the main function"); }