From 9832490ebe3c6b6e38c6ba52e7f5d5101d6f7c83 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 20 May 2020 11:36:00 +0200 Subject: Simplify: Remove Arc in Model Signed-off-by: Matthias Beyer --- src/model.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/model.rs b/src/model.rs index b81ea17..85fcf22 100644 --- a/src/model.rs +++ b/src/model.rs @@ -27,7 +27,7 @@ use crate::types::util::IPFSHash; use crate::types::util::IPNSHash; #[derive(Clone)] -pub struct Model(Arc); +pub struct Model(IpfsClient); impl std::fmt::Debug for Model{ fn fmt(&self, f: &mut std::fmt::Formatter) -> RResult<(), std::fmt::Error> { @@ -39,8 +39,7 @@ impl Model { pub fn new(host: &str, port: u16) -> Result { debug!("Creating new Model object: {}:{}", host, port); IpfsClient::from_str(&format!("{}:{}", host, port)) - .map(Arc::new) - .map(|c| Model(c)) + .map(Model) .map_err(|e| Error::from(e.compat())) } @@ -54,7 +53,6 @@ impl Model { pub(crate) async fn get_raw_bytes>(&self, hash: H) -> Result, Error> { debug!("Get: {}", hash.as_ref()); self.0 - .clone() .cat(hash.as_ref()) .map_ok(|b| b.to_vec()) .try_concat() @@ -65,7 +63,6 @@ impl Model { pub(crate) async fn put_raw_bytes(&self, data: Vec) -> Result { debug!("Put: {:?}", data); self.0 - .clone() .add(Cursor::new(data)) .await .map(|res| IPFSHash::from(res.hash)) @@ -75,7 +72,6 @@ impl Model { pub(crate) async fn publish(&self, key: &str, hash: &str) -> Result { debug!("Publish: {:?} -> {:?}", key, hash); self.0 - .clone() .name_publish(hash, false, None, None, Some(key)) .await .map(|res| IPNSHash::from(res.value)) @@ -84,7 +80,6 @@ impl Model { pub(crate) async fn resolve(&self, ipns: IPNSHash) -> Result { self.0 - .clone() .name_resolve(Some(&ipns), true, false) .await .map(|res| IPFSHash::from(res.path)) -- cgit v1.2.3