imessage_database/error/
plist.rs1use crabstep::error::TypedStreamError;
6
7use crate::error::handwriting::HandwritingError;
8use crate::error::streamtyped::StreamTypedError;
9use std::fmt::{Display, Formatter, Result};
10
11#[derive(Debug)]
13pub enum PlistParseError {
14 MissingKey(String),
16 NoValueAtIndex(usize),
18 InvalidType(String, String),
20 InvalidTypeIndex(usize, String),
22 InvalidDictionarySize(usize, usize),
24 NoPayload,
26 WrongMessageType,
28 InvalidEditedMessage(String),
30 StreamTypedError(StreamTypedError),
32 TypedStreamError(TypedStreamError),
34 HandwritingError(HandwritingError),
36 DigitalTouchError,
38}
39
40impl Display for PlistParseError {
41 fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
42 match self {
43 PlistParseError::MissingKey(key) => write!(fmt, "Expected key {key}, found nothing!"),
44 PlistParseError::NoValueAtIndex(idx) => {
45 write!(fmt, "Payload referenced index {idx}, but there is no data!")
46 }
47 PlistParseError::InvalidType(key, value) => {
48 write!(fmt, "Invalid data found at {key}, expected {value}")
49 }
50 PlistParseError::InvalidTypeIndex(idx, value) => {
51 write!(
52 fmt,
53 "Invalid data found at object index {idx}, expected {value}"
54 )
55 }
56 PlistParseError::InvalidDictionarySize(a, b) => write!(
57 fmt,
58 "Invalid dictionary size, found {a} keys and {b} values"
59 ),
60 PlistParseError::NoPayload => write!(fmt, "Unable to acquire payload data!"),
61 PlistParseError::WrongMessageType => write!(fmt, "Message is not an app message!"),
62 PlistParseError::InvalidEditedMessage(message) => {
63 write!(fmt, "Unable to parse message from binary data: {message}")
64 }
65 PlistParseError::StreamTypedError(why) => write!(fmt, "{why}"),
66 PlistParseError::HandwritingError(why) => write!(fmt, "{why}"),
67 PlistParseError::DigitalTouchError => {
68 write!(fmt, "Unable to parse Digital Touch Message!")
69 }
70 PlistParseError::TypedStreamError(typed_stream_error) => {
71 write!(fmt, "TypedStream error: {typed_stream_error}")
72 }
73 }
74 }
75}
76
77impl From<TypedStreamError> for PlistParseError {
78 fn from(error: TypedStreamError) -> Self {
79 PlistParseError::TypedStreamError(error)
80 }
81}
82
83impl From<StreamTypedError> for PlistParseError {
84 fn from(error: StreamTypedError) -> Self {
85 PlistParseError::StreamTypedError(error)
86 }
87}