rusmpp_extra/encoding/gsm7bit/
errors.rs1use crate::concatenation::MAX_PARTS;
2
3#[derive(Debug, thiserror::Error, PartialEq, Eq)]
5pub enum Gsm7BitEncodeError {
6 #[error("Input contains un-encodable character: '{0}'")]
8 UnencodableCharacter(char),
9}
10
11#[derive(Debug, thiserror::Error, PartialEq, Eq)]
13pub enum Gsm7BitConcatenateError {
14 #[error("Encoding error: {0}")]
16 Encode(
17 #[from]
18 #[source]
19 Gsm7BitEncodeError,
20 ),
21 #[error(
25 "Cannot fit even a single septet into a part with the given header and size constraints"
26 )]
27 PartCapacityExceeded,
28 #[error(
32 "A part would end with an escape (0x1B) septet, which is not allowed unless allow_split_extended_character=true"
33 )]
34 InvalidBoundary,
35 #[error("The number of parts exceeds the maximum allowed. actual: {actual}, max: {max}")]
36 PartsCountExceeded {
38 max: usize,
40 actual: usize,
42 },
43}
44
45impl Gsm7BitConcatenateError {
46 pub(crate) const fn parts_count_exceeded(actual: usize) -> Self {
47 Self::PartsCountExceeded {
48 max: MAX_PARTS,
49 actual,
50 }
51 }
52}