Wow, what a mess. Why was I making one giant file to contain everything? I'm splitting it out into several files and taking another crack at completing the decoder.
26 lines
784 B
Rust
26 lines
784 B
Rust
|
|
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");
|
|
}
|