imessage_database/error/
typedstream.rs1use std::{
6 array::TryFromSliceError,
7 fmt::{Display, Formatter, Result}, str::Utf8Error,
8};
9
10#[derive(Debug)]
12pub enum TypedStreamError {
13 OutOfBounds(usize, usize),
14 InvalidHeader,
15 SliceError(TryFromSliceError),
16 StringParseError(Utf8Error),
17 InvalidArray,
18 InvalidPointer(u8),
19}
20
21impl Display for TypedStreamError {
22 fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
23 match self {
24 TypedStreamError::OutOfBounds(idx, len) => {
25 write!(fmt, "Index {idx:x} is outside of range {len:x}!")
26 }
27 TypedStreamError::InvalidHeader => write!(fmt, "Invalid typedstream header!"),
28 TypedStreamError::SliceError(why) => {
29 write!(fmt, "Unable to slice source stream: {why}")
30 }
31 TypedStreamError::StringParseError(why) => write!(fmt, "Failed to parse string: {why}"),
32 TypedStreamError::InvalidArray => write!(fmt, "Failed to parse array data"),
33 TypedStreamError::InvalidPointer(why) => write!(fmt, "Failed to parse pointer: {why}"),
34 }
35 }
36}