diff --git a/src/content/mod.rs b/src/content/mod.rs index 4da9789..f47ce16 100644 --- a/src/content/mod.rs +++ b/src/content/mod.rs @@ -1 +1,2 @@ pub mod path; +pub mod read; diff --git a/src/content/read.rs b/src/content/read.rs new file mode 100644 index 0000000..4d5d525 --- /dev/null +++ b/src/content/read.rs @@ -0,0 +1,12 @@ +use crate::content::path::content_path; +use ssri::Integrity; +use std::path::Path; +use std::fs::File; + +pub fn open(cache: &Path, sri: &Integrity) -> std::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) +} diff --git a/src/lib.rs b/src/lib.rs index d75732f..91ed62f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,2 +1,3 @@ mod content; pub use crate::content::path; +pub use crate::content::read;