From 140265b713bb4755a2d12bc57a710302f9abffa2 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sun, 16 Jun 2019 22:20:09 +0200 Subject: [PATCH] Cleanup and use internal result type --- src/cache.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cache.rs b/src/cache.rs index 8318b98..fd0aacf 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -1,4 +1,4 @@ -use crate::Error; +use crate::error::{Error, Result}; use std::{ borrow::Cow, fs::{create_dir_all, File, OpenOptions}, @@ -17,7 +17,7 @@ pub(crate) enum CacheState<'a> { } impl<'a> CacheState<'a> { - pub(crate) fn read_from_file(path: impl AsRef, head: &str) -> Result { + pub(crate) fn read_from_file(path: impl AsRef, head: &str) -> Result { if path.as_ref().exists() { let cache: Cache = serde_json::from_reader(BufReader::new(File::open(path)?))?; if cache.head == head { @@ -49,7 +49,7 @@ pub(crate) struct Cache<'a> { } impl<'a> Cache<'a> { - pub(crate) fn write_to_file(&self, path: impl AsRef) -> Result<(), Error> { + pub(crate) fn write_to_file(&self, path: impl AsRef) -> Result<()> { create_dir_all(path.as_ref().parent().ok_or(Error::Internal)?)?; serde_json::to_writer( OpenOptions::new()