From 277c31237ab6c4bedc6d78f52a8f0fc453149978 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 15 Feb 2016 13:19:34 +0100 Subject: [PATCH] lib: Add remove_link() --- libimaglink/src/internal.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libimaglink/src/internal.rs b/libimaglink/src/internal.rs index 18e4dfae..c34476c8 100644 --- a/libimaglink/src/internal.rs +++ b/libimaglink/src/internal.rs @@ -25,6 +25,13 @@ pub fn add_link(header: &mut EntryHeader, link: Link) -> Result<()> { }) } +pub fn remove_link(header: &mut EntryHeader, link: Link) -> Result<()> { + get_links(header).and_then(|mut links| { + links.remove(link); + set_links(header, links).map(|_| ()) + }) +} + fn process_rw_result(links: StoreResult>) -> Result { if links.is_err() { let lerr = LinkError::new(LinkErrorKind::EntryHeaderReadError,