From 38557e9a9b3288fd57d49b41c9512f9ead7a4d1a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 28 Jun 2016 22:54:43 +0200 Subject: [PATCH] impl Ref::delete() --- libimagref/src/reference.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libimagref/src/reference.rs b/libimagref/src/reference.rs index 8000e403..d10953e5 100644 --- a/libimagref/src/reference.rs +++ b/libimagref/src/reference.rs @@ -38,6 +38,16 @@ impl<'a> Ref<'a> { } } + /// Delete this ref + /// + /// If the returned Result contains an error, the ref might not be deleted. + pub fn delete(self, store: &'a Store) -> Result<()> { + store + .delete(self.0.get_location().clone()) + .map_err(Box::new) + .map_err(|e| REK::StoreWriteError.into_error_with_cause(e)) + } + fn read_reference(fle: &FileLockEntry<'a>) -> Result { match fle.get_header().read("ref.reference") { Ok(Some(Value::String(s))) => Ok(PathBuf::from(s)),