From 685e35d302873d3047ef86dd8904e769202d23cf Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 20 May 2020 11:20:12 +0200 Subject: Unite ipfs-api client abstraction into one "Model" type Signed-off-by: Matthias Beyer --- src/repository/repository.rs | 71 -------------------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 src/repository/repository.rs (limited to 'src/repository/repository.rs') diff --git a/src/repository/repository.rs b/src/repository/repository.rs deleted file mode 100644 index cc940c6..0000000 --- a/src/repository/repository.rs +++ /dev/null @@ -1,71 +0,0 @@ -use std::io::Cursor; -use std::sync::Arc; -use std::ops::Deref; - -use ipfs_api::IpfsClient; -use anyhow::Error; -use futures::future::Future; -use futures::stream::Stream; - -use serde_json::from_str as serde_json_from_str; -use serde_json::to_string as serde_json_to_str; -use serde::Serialize; -use serde::de::DeserializeOwned; -use chrono::NaiveDateTime; - -use crate::types::block::Block; -use crate::types::content::Content; -use crate::types::payload::Payload; -use crate::types::util::IPFSHash; -use crate::types::util::IPNSHash; -use crate::repository::client::TypedClientFassade; - - -/// High-level Client abstraction -/// -/// Still a low-level interface though, because we're still operating on the repository directly. -/// -/// Should not be used too extensively, but rather through the "Profile" type, which represents the -/// profile of a user. -#[derive(Debug, Clone)] -pub struct Repository(TypedClientFassade); - -impl Deref for Repository { - type Target = TypedClientFassade; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl Repository { - pub fn new(host: &str, port: u16) -> Result { - TypedClientFassade::new(host, port).map(Repository) - } - - pub async fn get_block(&self, hash: H) -> Result - where H: AsRef - { - self.0.get_typed(hash).await - } - - pub async fn put_block(&self, b: B) -> Result - where B: AsRef - { - self.0.put_typed(b.as_ref()).await - } - - pub async fn get_content(&self, hash: H) -> Result - where H: AsRef - { - self.0.get_typed(hash).await - } - - pub async fn put_content(&self, c: C) -> Result - where C: AsRef - { - self.0.put_typed(c.as_ref()).await - } - -} - -- cgit v1.2.3