imessage_database/error/
streamtyped.rs

1/*!
2 Errors that can happen when parsing `typedstream` data. This module is for the legacy simple `typedstream` parser.
3*/
4
5use std::fmt::{Display, Formatter, Result};
6
7/// Errors that can happen when parsing `typedstream` data
8#[derive(Debug)]
9pub enum StreamTypedError {
10    /// Error when the expected start pattern is not found
11    NoStartPattern,
12    /// Error when the expected end pattern is not found
13    NoEndPattern,
14    /// Error when the prefix length does not match the standard
15    InvalidPrefix,
16    /// Error when the timestamp cannot be parsed as a valid integer
17    InvalidTimestamp,
18}
19
20impl Display for StreamTypedError {
21    fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
22        match self {
23            StreamTypedError::NoStartPattern => write!(fmt, "No start pattern found!"),
24            StreamTypedError::NoEndPattern => write!(fmt, "No end pattern found!"),
25            StreamTypedError::InvalidPrefix => write!(fmt, "Prefix length is not standard!"),
26            StreamTypedError::InvalidTimestamp => write!(fmt, "Timestamp integer is not valid!"),
27        }
28    }
29}