From 3b02a307889863f9c80709ce5c5727ea3de094d3 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 21 Feb 2016 14:28:55 +0100 Subject: [PATCH] Move Link/Links type to external linking code --- libimaglink/src/external.rs | 53 +++++++++++++++++++++++++++++++++++- libimaglink/src/link.rs | 54 ------------------------------------- 2 files changed, 52 insertions(+), 55 deletions(-) delete mode 100644 libimaglink/src/link.rs 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, +} + +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()); + } + +} + +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 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, -} - -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()); - } - -} - -impl Into for Link { - - fn into(self) -> String { - self.link - } - -} - -impl Into> for Links { - - fn into(self) -> Vec { - self.links - } - -} -