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 PollError,
40}
41
42impl Display for PlistParseError {
43 fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
44 match self {
45 PlistParseError::MissingKey(key) => write!(fmt, "Expected key {key}, found nothing!"),
46 PlistParseError::NoValueAtIndex(idx) => {
47 write!(fmt, "Payload referenced index {idx}, but there is no data!")
48 }
49 PlistParseError::InvalidType(key, value) => {
50 write!(fmt, "Invalid data found at {key}, expected {value}")
51 }
52 PlistParseError::InvalidTypeIndex(idx, value) => {
53 write!(
54 fmt,
55 "Invalid data found at object index {idx}, expected {value}"
56 )
57 }
58 PlistParseError::InvalidDictionarySize(a, b) => write!(
59 fmt,
60 "Invalid dictionary size, found {a} keys and {b} values"
61 ),
62 PlistParseError::NoPayload => write!(fmt, "Unable to acquire payload data!"),
63 PlistParseError::WrongMessageType => write!(fmt, "Message is not an app message!"),
64 PlistParseError::InvalidEditedMessage(message) => {
65 write!(fmt, "Unable to parse message from binary data: {message}")
66 }
67 PlistParseError::StreamTypedError(why) => write!(fmt, "{why}"),
68 PlistParseError::HandwritingError(why) => write!(fmt, "{why}"),
69 PlistParseError::DigitalTouchError => {
70 write!(fmt, "Unable to parse Digital Touch Message!")
71 }
72 PlistParseError::TypedStreamError(typed_stream_error) => {
73 write!(fmt, "TypedStream error: {typed_stream_error}")
74 }
75 PlistParseError::PollError => write!(fmt, "Unable to parse Poll Message!"),
76 }
77 }
78}
79
80impl From<TypedStreamError> for PlistParseError {
81 fn from(error: TypedStreamError) -> Self {
82 PlistParseError::TypedStreamError(error)
83 }
84}
85
86impl From<StreamTypedError> for PlistParseError {
87 fn from(error: StreamTypedError) -> Self {
88 PlistParseError::StreamTypedError(error)
89 }
90}