Move Link/Links type to external linking code

This commit is contained in:
Matthias Beyer 2016-02-21 14:28:55 +01:00
parent b8766a224e
commit 3b02a30788
2 changed files with 52 additions and 55 deletions

View File

@ -1,13 +1,64 @@
use std::convert::Into;
use libimagstore::store::Entry; use libimagstore::store::Entry;
use libimagstore::store::EntryHeader; use libimagstore::store::EntryHeader;
use error::{LinkError, LinkErrorKind}; use error::{LinkError, LinkErrorKind};
use link::{Link, Links};
use result::Result; use result::Result;
use toml::Value; use toml::Value;
use toml::Table; use toml::Table;
#[derive(PartialOrd, Ord, Eq, PartialEq, Clone, Debug)]
pub struct Link {
link: String
}
impl Link {
pub fn new(s: String) -> Link {
Link { link: s }
}
}
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Links {
links: Vec<Link>,
}
impl Links {
pub fn new(s: Vec<Link>) -> 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());
}
}
impl Into<String> for Link {
fn into(self) -> String {
self.link
}
}
impl Into<Vec<Link>> for Links {
fn into(self) -> Vec<Link> {
self.links
}
}
pub trait ExternalLinker { pub trait ExternalLinker {
/// get the external link from the implementor object /// get the external link from the implementor object

View File

@ -1,54 +0,0 @@
use std::convert::Into;
use libimagstore::store::Entry;
#[derive(PartialOrd, Ord, Eq, PartialEq, Clone, Debug)]
pub struct Link {
link: String
}
impl Link {
pub fn new(s: String) -> Link {
Link { link: s }
}
}
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Links {
links: Vec<Link>,
}
impl Links {
pub fn new(s: Vec<Link>) -> 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());
}
}
impl Into<String> for Link {
fn into(self) -> String {
self.link
}
}
impl Into<Vec<Link>> for Links {
fn into(self) -> Vec<Link> {
self.links
}
}