2016-02-03 14:47:14 +00:00
|
|
|
use libimagstore::store::EntryHeader;
|
|
|
|
|
|
|
|
use error::{LinkError, LinkErrorKind};
|
|
|
|
use link::{Link, Links};
|
|
|
|
use result::Result;
|
|
|
|
|
2016-02-07 15:25:17 +00:00
|
|
|
use toml::Value;
|
|
|
|
|
2016-02-03 14:47:14 +00:00
|
|
|
pub fn get_links(header: &EntryHeader) -> Result<Links> {
|
2016-02-07 15:25:17 +00:00
|
|
|
process_rw_result(header.read("imag.links"))
|
2016-02-03 14:47:14 +00:00
|
|
|
}
|
|
|
|
|
2016-02-07 15:40:33 +00:00
|
|
|
/// Set the links in a header and return the old links, if any.
|
2016-02-03 14:47:14 +00:00
|
|
|
pub fn set_links(header: &mut EntryHeader, links: Links) -> Result<Links> {
|
2016-02-07 15:40:33 +00:00
|
|
|
let links : Vec<Link> = links.into();
|
|
|
|
let links : Vec<Value> = links.into_iter().map(|link| Value::String(link.into())).collect();
|
|
|
|
process_rw_result(header.set("imag.links", Value::Array(links)))
|
2016-02-03 14:47:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn add_link(header: &mut EntryHeader, link: Link) -> Result<()> {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
|