bin_encode_decode/common/error/
impl.rs

1use super::*;
2
3/// Provides display formatting for EncodeError.
4///
5/// Implements human-readable error messages for encoding failures.
6impl fmt::Display for EncodeError {
7    /// Formats the EncodeError for display purposes.
8    ///
9    /// # Arguments
10    ///
11    /// - `&mut fmt::Formatter<'_>` - The formatter to use.
12    ///
13    /// # Returns
14    ///
15    /// - `fmt::Result` - Result of the formatting operation.
16    #[inline(always)]
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        match self {
19            EncodeError::CharsetError => write!(
20                f,
21                "EncodeError: Charset is invalid. Please ensure the charset contains exactly {CHARSET_LEN} unique characters."
22            ),
23        }
24    }
25}
26
27/// Provides display formatting for DecodeError.
28///
29/// Implements human-readable error messages for decoding failures.
30impl fmt::Display for DecodeError {
31    /// Formats the DecodeError for display purposes.
32    ///
33    /// # Arguments
34    ///
35    /// - `&mut fmt::Formatter<'_>` - The formatter to use.
36    ///
37    /// # Returns
38    ///
39    /// - `fmt::Result` - Result of the formatting operation.
40    #[inline(always)]
41    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
42        match self {
43            DecodeError::CharsetError => write!(
44                f,
45                "DecodeError: Charset is invalid. Please ensure the charset contains exactly {CHARSET_LEN} unique characters."
46            ),
47        }
48    }
49}