Implement: external::get_link()

This commit is contained in:
Matthias Beyer 2016-02-03 19:59:22 +01:00
parent e6e9a1a19e
commit 18de6b80d5

View file

@ -1,10 +1,26 @@
use libimagstore::store::EntryHeader; use libimagstore::store::EntryHeader;
use error::{LinkError, LinkErrorKind};
use link::{Link, Links}; use link::{Link, Links};
use result::Result; use result::Result;
pub fn get_link(header: &EntryHeader) -> Result<Link> { use toml::Value;
unimplemented!() use toml::Table;
pub fn get_link(header: &EntryHeader) -> Result<Option<Link>> {
let uri = header.read("imag.content.uri");
if uri.is_err() {
let kind = LinkErrorKind::EntryHeaderReadError;
let lerr = LinkError::new(kind, Some(Box::new(uri.err().unwrap())));
return Err(lerr);
}
let uri = uri.unwrap();
match uri {
Some(Value::String(s)) => Ok(Some(Link::new(s))),
_ => Err(LinkError::new(LinkErrorKind::ExistingLinkTypeWrong, None)),
}
} }
/// Set an external link in the header /// Set an external link in the header