imessage_database/error/
attachment.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*!
 Errors that can happen when parsing attachment data.
*/

use std::{
    fmt::{Display, Formatter, Result},
    io::Error,
};

/// Errors that can happen when working with attachment table data
#[derive(Debug)]
pub enum AttachmentError {
    FileNotFound(String),
    Unreadable(String, Error),
}

impl Display for AttachmentError {
    fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
        match self {
            AttachmentError::FileNotFound(path) => {
                write!(fmt, "File not found at location: {path}")
            }
            AttachmentError::Unreadable(path, why) => {
                write!(fmt, "Unable to read file at {path}: {why}")
            }
        }
    }
}