From 1890f31b514a2d9de59baffe2a812bcd56102a1b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 28 Apr 2020 19:30:04 +0200 Subject: Remove repository/profile module Signed-off-by: Matthias Beyer --- src/repository/mod.rs | 9 +--- src/repository/profile.rs | 102 ---------------------------------------------- 2 files changed, 2 insertions(+), 109 deletions(-) delete mode 100644 src/repository/profile.rs (limited to 'src') diff --git a/src/repository/mod.rs b/src/repository/mod.rs index f837ecc..dc00895 100644 --- a/src/repository/mod.rs +++ b/src/repository/mod.rs @@ -1,7 +1,2 @@ -mod client; -mod repository; -mod profile; - -pub use repository::Repository; -pub use profile::ProfileName; - +pub mod client; +pub mod repository; diff --git a/src/repository/profile.rs b/src/repository/profile.rs deleted file mode 100644 index bc62d9f..0000000 --- a/src/repository/profile.rs +++ /dev/null @@ -1,102 +0,0 @@ -use failure::Error; -use futures::stream::{self, Stream, StreamExt}; -use futures::future; -use futures::Future; -use futures::FutureExt; - -use crate::types::util::IPNSHash; -use crate::types::util::IPFSHash; -use crate::types::block::Block; -use crate::repository::Repository; - -#[derive(Clone, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)] -pub struct ProfileName(String); - -impl From for ProfileName { - fn from(s: String) -> Self { - ProfileName(s) - } -} - -/// A profile -/// -/// A profile can be _any_ profile, not only the profile of the user -pub struct Profile { - repository: Repository, - head: IPFSHash, -} - -impl Profile { - - /// Create a new Profile. - /// - /// One does not want this most of the time, see `load`. Use this only for creating a - /// completely new profile - pub fn new(repository: Repository) -> Result { - unimplemented!() - } - - /// Load a profile from the repository - pub fn load(repository: Repository, key: IPNSHash) -> Result { - unimplemented!() - } - - pub fn blocks(&self) -> impl Stream> { - stream::unfold((self.repository.clone(), vec![self.head.clone()]), move |(repo, mut state)| { - async { - if let Some(hash) = state.pop() { - match repo - .get_block(hash) - .await - .map(move |block| { - block.parents().iter().for_each(|parent| { - state.push(parent.clone()) - }); - - (block, state) - }) - .map(Some) - .transpose() - { - Some(Ok((item, state))) => Some((Ok(item), (repo, state))), - Some(Err(e)) => Some((Err(e), (repo, vec![]))), - None => None, - } - } else { - None - } - } - }) - } -} - - -/// The profile of the user of the application -/// -/// Internally this wraps the `Profile` type, but it provides more functionality, for example -/// posting new content. -/// -pub struct UserProfile { - profile: Profile -} - -impl UserProfile { - - /// Create a new Profile. - /// - /// One does not want this most of the time, see `load`. Use this only for creating a - /// completely new profile - pub fn new(repository: Repository) -> Result { - Ok(UserProfile { - profile: Profile::new(repository)?, - }) - } - - /// Load a profile from the repository - pub fn load(repository: Repository, key: IPNSHash) -> Result { - Ok(UserProfile { - profile: Profile::load(repository, key)?, - }) - } - -} -- cgit v1.2.3