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