imessage_database/error/
plist.rs1use crate::error::handwriting::HandwritingError;
6use crate::error::streamtyped::StreamTypedError;
7use std::fmt::{Display, Formatter, Result};
8
9#[derive(Debug)]
11pub enum PlistParseError {
12 MissingKey(String),
13 NoValueAtIndex(usize),
14 InvalidType(String, String),
15 InvalidTypeIndex(usize, String),
16 InvalidDictionarySize(usize, usize),
17 NoPayload,
18 WrongMessageType,
19 InvalidEditedMessage(String),
20 StreamTypedError(StreamTypedError),
21 HandwritingError(HandwritingError),
22 DigitalTouchError,
23}
24
25impl Display for PlistParseError {
26 fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
27 match self {
28 PlistParseError::MissingKey(key) => write!(fmt, "Expected key {key}, found nothing!"),
29 PlistParseError::NoValueAtIndex(idx) => {
30 write!(fmt, "Payload referenced index {idx}, but there is no data!")
31 }
32 PlistParseError::InvalidType(key, value) => {
33 write!(fmt, "Invalid data found at {key}, expected {value}")
34 }
35 PlistParseError::InvalidTypeIndex(idx, value) => {
36 write!(
37 fmt,
38 "Invalid data found at object index {idx}, expected {value}"
39 )
40 }
41 PlistParseError::InvalidDictionarySize(a, b) => write!(
42 fmt,
43 "Invalid dictionary size, found {a} keys and {b} values"
44 ),
45 PlistParseError::NoPayload => write!(fmt, "Unable to acquire payload data!"),
46 PlistParseError::WrongMessageType => write!(fmt, "Message is not an app message!"),
47 PlistParseError::InvalidEditedMessage(message) => {
48 write!(fmt, "Unable to parse message from binary data: {message}")
49 }
50 PlistParseError::StreamTypedError(why) => write!(fmt, "{why}"),
51 PlistParseError::HandwritingError(why) => write!(fmt, "{why}"),
52 PlistParseError::DigitalTouchError => {
53 write!(fmt, "Unable to parse Digital Touch Message!")
54 }
55 }
56 }
57}