tsfile_writer/writer/
errors.rs

1//! Default Errors for the TsFile crate
2use std::io::Error;
3
4#[derive(Debug)]
5pub enum TsFileError {
6    Error { source: Option<String> }, // Generic Error
7    IoError { source: std::io::Error },
8    WriteError,
9    OutOfOrderData,
10    IllegalState { source: Option<String> },
11    Compression,
12    WrongTypeForSeries,
13    Encoding,
14}
15
16impl PartialEq for TsFileError {
17    fn eq(&self, other: &Self) -> bool {
18        match self {
19            TsFileError::Error { source: a } => match other {
20                TsFileError::Error { source: b } => a == b,
21                _ => false,
22            },
23            TsFileError::IoError { .. } => false,
24            TsFileError::WriteError => matches!(other, TsFileError::WriteError),
25            TsFileError::OutOfOrderData => matches!(other, TsFileError::OutOfOrderData),
26            TsFileError::IllegalState { source: a } => match other {
27                TsFileError::IllegalState { source: b } => a == b,
28                _ => false,
29            },
30            TsFileError::Compression => matches!(other, TsFileError::Compression),
31            TsFileError::WrongTypeForSeries => matches!(other, TsFileError::WrongTypeForSeries),
32            TsFileError::Encoding => matches!(other, TsFileError::Encoding),
33        }
34    }
35}
36
37impl From<std::io::Error> for TsFileError {
38    fn from(e: Error) -> Self {
39        TsFileError::IoError { source: e }
40    }
41}