diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-02-21 14:28:55 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-03-11 15:15:02 +0100 |
commit | 3b02a307889863f9c80709ce5c5727ea3de094d3 (patch) | |
tree | 6a0f99b681e5aac92fe422d2a948535ec6347440 /libimaglink | |
parent | b8766a224ea482bad7e3f63e1e68560e54baf814 (diff) |
Move Link/Links type to external linking code
Diffstat (limited to 'libimaglink')
-rw-r--r-- | libimaglink/src/external.rs | 53 | ||||
-rw-r--r-- | libimaglink/src/link.rs | 54 |
2 files changed, 52 insertions, 55 deletions
diff --git a/libimaglink/src/external.rs b/libimaglink/src/external.rs index 52f1fa5f..b9168b20 100644 --- a/libimaglink/src/external.rs +++ b/libimaglink/src/external.rs @@ -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 diff --git a/libimaglink/src/link.rs b/libimaglink/src/link.rs deleted file mode 100644 index c811f98b..00000000 --- a/libimaglink/src/link.rs +++ /dev/null @@ -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 - } - -} - |