lib: Add remove_link()

This commit is contained in:
Matthias Beyer 2016-02-15 13:19:34 +01:00
parent b7a5f57e3a
commit 277c31237a

View file

@ -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<Option<Value>>) -> Result<Links> { fn process_rw_result(links: StoreResult<Option<Value>>) -> Result<Links> {
if links.is_err() { if links.is_err() {
let lerr = LinkError::new(LinkErrorKind::EntryHeaderReadError, let lerr = LinkError::new(LinkErrorKind::EntryHeaderReadError,