1#[derive(Clone, Debug, PartialEq, Eq)]
8pub enum SsimError {
9 SizeMismatch {
11 img1_width: u32,
12 img1_height: u32,
13 img2_width: u32,
14 img2_height: u32,
15 },
16 InputTooSmall {
18 width: u32,
19 height: u32,
20 minimum: u32,
21 },
22 Options(String),
24}
25
26impl std::fmt::Display for SsimError {
27 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28 match self {
29 SsimError::SizeMismatch {
30 img1_width,
31 img1_height,
32 img2_width,
33 img2_height,
34 } => write!(
35 f,
36 "Image sizes do not match: {}x{} vs {}x{}",
37 img1_width, img1_height, img2_width, img2_height
38 ),
39 SsimError::InputTooSmall {
40 width,
41 height,
42 minimum,
43 } => write!(
44 f,
45 "Image {}x{} is too small for this metric: needs at least {}x{}",
46 width, height, minimum, minimum
47 ),
48 SsimError::Options(e) => write!(f, "Invalid metric options: {}", e),
49 }
50 }
51}
52
53impl std::error::Error for SsimError {}