imessage_database/error/
handwriting.rs1use std::fmt::{Display, Formatter, Result};
6
7#[derive(Debug)]
9pub enum HandwritingError {
10 ProtobufError(protobuf::Error),
12 InvalidFrameSize(usize),
14 XZError(lzma_rs::error::Error),
16 CompressionUnknown,
18 InvalidStrokesLength(usize, usize),
20 ConversionError,
22 DecompressedNotSet,
24 InvalidDecompressedLength(usize, usize),
26 ResizeError(std::num::TryFromIntError),
28}
29
30impl Display for HandwritingError {
31 fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
32 match self {
33 HandwritingError::ProtobufError(why) => {
34 write!(fmt, "failed to parse handwriting protobuf: {why}")
35 }
36 HandwritingError::InvalidFrameSize(size) => write!(fmt, "expected size 8, got {size}"),
37 HandwritingError::XZError(why) => write!(fmt, "failed to decompress xz: {why}"),
38 HandwritingError::CompressionUnknown => write!(fmt, "compress method unknown"),
39 HandwritingError::InvalidStrokesLength(index, length) => {
40 write!(fmt, "can't access index {index} on array length {length}")
41 }
42 HandwritingError::ConversionError => write!(fmt, "failed to convert num"),
43 HandwritingError::DecompressedNotSet => {
44 write!(fmt, "decompressed length not set on compressed message")
45 }
46 HandwritingError::InvalidDecompressedLength(expected, got) => {
47 write!(fmt, "expected decompressed length of {expected}, got {got}")
48 }
49 HandwritingError::ResizeError(why) => {
50 write!(fmt, "failed to resize handwriting coordinates: {why}")
51 }
52 }
53 }
54}