From 8bf623b8efab138f9a247edc45e477a08ab9213c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Wed, 5 Jun 2019 11:33:45 +0200 Subject: [PATCH] fix(write): use shared Error type for write() --- src/content/write.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/content/write.rs b/src/content/write.rs index 0a6c0c2..304bb99 100644 --- a/src/content/write.rs +++ b/src/content/write.rs @@ -1,11 +1,14 @@ -use atomicwrites::{AtomicFile, AllowOverwrite}; -use crate::content::path; -use ssri::{Algorithm, Integrity}; use std::fs::DirBuilder; -use std::io::{self, prelude::*}; +use std::io::prelude::*; use std::path::Path; -pub fn write(cache: &Path, data: &[u8]) -> io::Result { +use atomicwrites::{AtomicFile, AllowOverwrite}; +use ssri::{Algorithm, Integrity}; + +use crate::content::path; +use crate::errors::Error; + +pub fn write(cache: &Path, data: &[u8]) -> Result { let sri = Integrity::from(&data, Algorithm::Sha256); let cpath = path::content_path(&cache, &sri); DirBuilder::new().recursive(true).create(cpath.parent().unwrap())?;