Add QoiDecoder, handle padding properly + refactor

This commit is contained in:
Ivan Smirnov 2022-01-02 00:02:08 +03:00
commit 0eb8a7ade7
4 changed files with 87 additions and 45 deletions

View file

@ -16,6 +16,7 @@ pub enum Error {
InvalidMagic { magic: u32 },
UnexpectedBufferEnd,
InvalidColorSpace { colorspace: u8 },
InvalidPadding,
}
pub type Result<T> = StdResult<T, Error>;
@ -51,6 +52,9 @@ impl Display for Error {
Self::InvalidColorSpace { colorspace } => {
write!(f, "invalid color space: {} (expected 0 or 1)", colorspace)
}
Self::InvalidPadding => {
write!(f, "invalid padding (stream end marker)")
}
}
}
}