1use alloc::string::String;
10use core::fmt::{Debug, Formatter};
11
12pub enum BmpDecoderErrors {
14 InvalidMagicBytes,
16 TooSmallBuffer(usize, usize),
19 GenericStatic(&'static str),
21 Generic(String),
23 TooLargeDimensions(&'static str, usize, usize),
26 OverFlowOccurred
28}
29
30impl Debug for BmpDecoderErrors {
31 fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
32 match self {
33 Self::InvalidMagicBytes => {
34 writeln!(f, "Invalid magic bytes, file does not start with BM")
35 }
36 Self::TooSmallBuffer(expected, found) => {
37 writeln!(
38 f,
39 "Too small of buffer, expected {} but found {}",
40 expected, found
41 )
42 }
43 Self::GenericStatic(header) => {
44 writeln!(f, "{}", header)
45 }
46 Self::TooLargeDimensions(dimension, expected, found) => {
47 writeln!(
48 f,
49 "Too large dimensions for {dimension} , {found} exceeds {expected}"
50 )
51 }
52 Self::Generic(message) => {
53 writeln!(f, "{}", message)
54 }
55 Self::OverFlowOccurred => {
56 writeln!(f, "Overflow occurred")
57 }
58 }
59 }
60}