diff --git a/src/content/read.rs b/src/content/read.rs index 4d5d525..4c30286 100644 --- a/src/content/read.rs +++ b/src/content/read.rs @@ -1,12 +1,21 @@ use crate::content::path::content_path; use ssri::Integrity; use std::path::Path; -use std::fs::File; +use std::fs::{self, File}; +use std::io; -pub fn open(cache: &Path, sri: &Integrity) -> std::io::Result { +pub fn open(cache: &Path, sri: &Integrity) -> io::Result { File::open(content_path(&cache, &sri)) } -pub fn copy(cache: &Path, sri: &Integrity, to: &Path) -> std::io::Result { - std::fs::copy(content_path(&cache, &sri), to) +pub fn read(cache: &Path, sri: &Integrity) -> io::Result> { + fs::read(content_path(&cache, &sri)) +} + +pub fn read_to_string(cache: &Path, sri: &Integrity) -> io::Result { + fs::read_to_string(content_path(&cache, &sri)) +} + +pub fn copy(cache: &Path, sri: &Integrity, to: &Path) -> io::Result { + fs::copy(content_path(&cache, &sri), to) }