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