Implement: external::get_link()
This commit is contained in:
parent
e6e9a1a19e
commit
18de6b80d5
1 changed files with 18 additions and 2 deletions
|
@ -1,10 +1,26 @@
|
|||
use libimagstore::store::EntryHeader;
|
||||
|
||||
use error::{LinkError, LinkErrorKind};
|
||||
use link::{Link, Links};
|
||||
use result::Result;
|
||||
|
||||
pub fn get_link(header: &EntryHeader) -> Result<Link> {
|
||||
unimplemented!()
|
||||
use toml::Value;
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue