aboutsummaryrefslogtreecommitdiff
path: root/src/cache.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cache.rs')
-rw-r--r--src/cache.rs28
1 files changed, 5 insertions, 23 deletions
diff --git a/src/cache.rs b/src/cache.rs
index 09c8512..7dd65cf 100644
--- a/src/cache.rs
+++ b/src/cache.rs
@@ -1,33 +1,15 @@
//! Caching support to prevent hitting the API a lot.
-use std::{error::Error, fmt, fs, path::Path};
+use std::{fs, path::Path};
+use thiserror::Error;
use xdg::BaseDirectories;
use super::APP_NAME;
-#[derive(Debug)]
+#[derive(Error, Debug)]
pub enum CacheError {
- Io(std::io::Error),
-}
-
-error_froms! { CacheError,
- err: std::io::Error => CacheError::Io(err),
-}
-
-impl fmt::Display for CacheError {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match *self {
- CacheError::Io(_) => write!(f, "cache input/output error"),
- }
- }
-}
-
-impl Error for CacheError {
- fn source(&self) -> Option<&(dyn Error + 'static)> {
- match *self {
- CacheError::Io(ref err) => Some(err),
- }
- }
+ #[error("Cache I/O error")]
+ Io(#[from] std::io::Error),
}
/// A generic cache.