Move Link/Links type to external linking code
This commit is contained in:
parent
b8766a224e
commit
3b02a30788
2 changed files with 52 additions and 55 deletions
|
@ -1,13 +1,64 @@
|
|||
use std::convert::Into;
|
||||
|
||||
use libimagstore::store::Entry;
|
||||
use libimagstore::store::EntryHeader;
|
||||
|
||||
use error::{LinkError, LinkErrorKind};
|
||||
use link::{Link, Links};
|
||||
use result::Result;
|
||||
|
||||
use toml::Value;
|
||||
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 {
|
||||
|
||||
/// get the external link from the implementor object
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in a new issue