1use std::path::PathBuf;
2use thiserror::Error;
3
4mod manager;
5mod types;
6
7pub use manager::CacheManager;
8pub use types::{CacheConfig, CacheHandle};
9#[derive(Error, Debug)]
10pub enum CacheError {
11 #[error("Failed to load image from {path}: {source}")]
12 ImageLoad { path: PathBuf, source: ImageLoadError },
13
14 #[error("Cache capacity reached ({current} images, maximum {maximum})")]
15 CapacityExceeded { current: usize, maximum: usize },
16
17 #[error("File system error: {0}")]
18 FileSystem(#[from] std::io::Error),
19
20 #[error("Configuration error: {0}")]
21 Config(String),
22}
23
24#[derive(Error, Debug)]
25pub enum ImageLoadError {
26 #[error("IO error: {0}")]
27 Io(#[from] std::io::Error),
28
29 #[error("Invalid image format: {0}")]
30 Format(String),
31}
32
33pub type CacheResult<T> = Result<T, CacheError>;
34pub type LoadResult<T> = Result<T, ImageLoadError>;