1use crate::core::fmt;
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11pub enum CompressionError {
12 DataError,
13 UnexpectedEof,
14 Unexpected,
15}
16
17impl fmt::Display for CompressionError {
18 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19 write!(f, "{}", self.description_in())
20 }
21}
22
23#[cfg(feature = "std")]
24impl ::std::error::Error for CompressionError {
25 fn description(&self) -> &str {
26 self.description_in()
27 }
28
29 fn cause(&self) -> Option<&dyn (::std::error::Error)> {
30 None
31 }
32}
33
34impl CompressionError {
35 fn description_in(&self) -> &str {
36 match *self {
37 CompressionError::DataError => "data integrity error in data",
38 CompressionError::UnexpectedEof => "file ends unexpectedly",
39 CompressionError::Unexpected => "unexpected error",
40 }
41 }
42}