From e98bfb17da0f4b862954e5f7636ea6284cd81367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Mon, 20 May 2019 18:11:58 -0700 Subject: [PATCH] feat(content): add baseline read functionality --- src/content/mod.rs | 1 + src/content/read.rs | 12 ++++++++++++ src/lib.rs | 1 + 3 files changed, 14 insertions(+) create mode 100644 src/content/read.rs 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;