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),
14 NoValueAtIndex(usize),
16 InvalidType(String, String),
18 InvalidTypeIndex(usize, String),
20 InvalidDictionarySize(usize, usize),
22 NoPayload,
24 WrongMessageType,
26 InvalidEditedMessage(String),
28 StreamTypedError(StreamTypedError),
30 HandwritingError(HandwritingError),
32 DigitalTouchError,
34}
35
36impl Display for PlistParseError {
37 fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
38 match self {
39 PlistParseError::MissingKey(key) => write!(fmt, "Expected key {key}, found nothing!"),
40 PlistParseError::NoValueAtIndex(idx) => {
41 write!(fmt, "Payload referenced index {idx}, but there is no data!")
42 }
43 PlistParseError::InvalidType(key, value) => {
44 write!(fmt, "Invalid data found at {key}, expected {value}")
45 }
46 PlistParseError::InvalidTypeIndex(idx, value) => {
47 write!(
48 fmt,
49 "Invalid data found at object index {idx}, expected {value}"
50 )
51 }
52 PlistParseError::InvalidDictionarySize(a, b) => write!(
53 fmt,
54 "Invalid dictionary size, found {a} keys and {b} values"
55 ),
56 PlistParseError::NoPayload => write!(fmt, "Unable to acquire payload data!"),
57 PlistParseError::WrongMessageType => write!(fmt, "Message is not an app message!"),
58 PlistParseError::InvalidEditedMessage(message) => {
59 write!(fmt, "Unable to parse message from binary data: {message}")
60 }
61 PlistParseError::StreamTypedError(why) => write!(fmt, "{why}"),
62 PlistParseError::HandwritingError(why) => write!(fmt, "{why}"),
63 PlistParseError::DigitalTouchError => {
64 write!(fmt, "Unable to parse Digital Touch Message!")
65 }
66 }
67 }
68}