pleiades_compression/
error.rs1use core::fmt;
4
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
8#[non_exhaustive]
9pub enum CompressionErrorKind {
10 InvalidMagic,
12 UnsupportedVersion,
14 ChecksumMismatch,
16 Truncated,
18 InvalidFormat,
20 UnsupportedEndianPolicy,
22 MissingBody,
24 MissingChannel,
26 OutOfRangeInstant,
28 UnsupportedTimeScale,
30 QuantizationOverflow,
32}
33
34#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
36#[derive(Clone, Debug, PartialEq, Eq)]
37pub struct CompressionError {
38 pub kind: CompressionErrorKind,
40 pub message: String,
42}
43
44impl CompressionError {
45 pub fn new(kind: CompressionErrorKind, message: impl Into<String>) -> Self {
47 Self {
48 kind,
49 message: message.into(),
50 }
51 }
52}
53
54impl fmt::Display for CompressionError {
55 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
56 write!(f, "{:?}: {}", self.kind, self.message)
57 }
58}
59
60impl std::error::Error for CompressionError {}