imessage_database/error/
attachment.rs

1/*!
2 Errors that can happen when parsing attachment data.
3*/
4
5use std::{
6    fmt::{Display, Formatter, Result},
7    io::Error,
8};
9
10/// Errors that can happen when working with attachment table data
11#[derive(Debug)]
12pub enum AttachmentError {
13    FileNotFound(String),
14    Unreadable(String, Error),
15}
16
17impl Display for AttachmentError {
18    fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
19        match self {
20            AttachmentError::FileNotFound(path) => {
21                write!(fmt, "File not found at location: {path}")
22            }
23            AttachmentError::Unreadable(path, why) => {
24                write!(fmt, "Unable to read file at {path}: {why}")
25            }
26        }
27    }
28}