rusmpp_extra/encoding/ucs2/
errors.rs1use crate::concatenation::MAX_PARTS;
2
3#[derive(Debug, thiserror::Error, PartialEq, Eq)]
5pub enum Ucs2EncodeError {
6 #[error("Input contains un-encodable character")]
8 UnencodableCharacter,
9}
10
11#[derive(Debug, thiserror::Error, PartialEq, Eq)]
13pub enum Ucs2ConcatenateError {
14 #[error("Encoding error: {0}")]
16 Encode(
17 #[from]
18 #[source]
19 Ucs2EncodeError,
20 ),
21 #[error(
25 "Cannot fit even a single character into a part with the given header and size constraints"
26 )]
27 PartCapacityExceeded,
28 #[error(
32 "A part would end with a leading surrogate, which is not allowed unless allow_split_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 Ucs2ConcatenateError {
46 pub(crate) const fn parts_count_exceeded(actual: usize) -> Self {
47 Self::PartsCountExceeded {
48 max: MAX_PARTS,
49 actual,
50 }
51 }
52}