bin_encode_decode/common/
error.rs

1use crate::*;
2
3#[derive(Debug, Clone)]
4pub enum EncodeError {
5    CharsetError,
6}
7
8impl fmt::Display for EncodeError {
9    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
10        match self {
11            EncodeError::CharsetError => write!(
12                f,
13                "EncodeError: Charset is invalid. Please ensure the charset contains exactly {} unique characters.",
14                CHARSET_LEN
15            ),
16        }
17    }
18}
19
20#[derive(Debug, Clone)]
21pub enum DecodeError {
22    CharsetError,
23}
24
25impl fmt::Display for DecodeError {
26    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27        match self {
28            DecodeError::CharsetError => write!(
29                f,
30                "DecodeError: Charset is invalid. Please ensure the charset contains exactly {} unique characters.",
31                CHARSET_LEN
32            ),
33        }
34    }
35}