use std::convert::Into;
use libimagstore::store::Entry;
use libimagstore::store::EntryHeader;
use error::{LinkError, LinkErrorKind};
use result::Result;
use toml::Value;
use toml::Table;
use url::Url;
#[derive(PartialOrd, Ord, Eq, PartialEq, Clone, Debug)]
pub struct Link {
link: String
}
impl Link {
pub fn new(s: String) -> Link {
Link { link: s }
}
pub fn is_valid(&self) -> bool {
Url::parse(&self.link[..]).is_ok()
}
}
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Links {
links: Vec,
}
impl Links {
pub fn new(s: Vec) -> Links {
Links { links: s }
}
pub fn add(&mut self, l: Link) {
self.links.push(l);
}
pub fn remove(&mut self, l: Link) {
self.links.retain(|link| l != link.clone());
}
pub fn all_valid(&self) -> bool {
self.links.iter().all(|l| l.is_valid())
}
}
impl Into for Link {
fn into(self) -> String {
self.link
}
}
impl Into> for Links {
fn into(self) -> Vec {
self.links
}
}
pub trait ExternalLinker {
/// get the external link from the implementor object
fn get_external_link(&self) -> Result