diff --git a/src/lib.rs b/src/lib.rs index 79e5ffe..2d4771a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ mod content; pub mod get; pub mod put; +pub mod rm; mod index; mod errors; diff --git a/src/rm.rs b/src/rm.rs new file mode 100644 index 0000000..9f4b667 --- /dev/null +++ b/src/rm.rs @@ -0,0 +1,25 @@ +use std::fs; +use std::path::Path; + +use ssri::Integrity; + +use crate::content::rm; +use crate::errors::Error; +use crate::index; + +pub fn entry(cache: &Path, key: &str) -> Result<(), Error> { + index::delete(&cache, &key) +} + +pub fn content(cache: &Path, sri: &Integrity) -> Result<(), Error> { + rm::rm(&cache, &sri) +} + +pub fn all(cache: &Path) -> Result<(), Error> { + for entry in cache.read_dir()? { + if let Ok(entry) = entry { + fs::remove_dir_all(entry.path())?; + } + } + Ok(()) +}