summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-04-28 19:30:04 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-04-28 20:26:27 +0200
commit1890f31b514a2d9de59baffe2a812bcd56102a1b (patch)
tree739a57e8a7676a162a13df15943290c9d3554958
parent98c328fffd7202d4819a2bb9f734ef63d1b8f38d (diff)
Remove repository/profile module
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/repository/mod.rs9
-rw-r--r--src/repository/profile.rs102
2 files changed, 2 insertions, 109 deletions
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<String> 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<Self, Error> {
- unimplemented!()
- }
-
- /// Load a profile from the repository
- pub fn load(repository: Repository, key: IPNSHash) -> Result<Self, Error> {
- unimplemented!()
- }
-
- pub fn blocks(&self) -> impl Stream<Item = Result<Block, Error>> {
- 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<Self, Error> {
- Ok(UserProfile {
- profile: Profile::new(repository)?,
- })
- }
-
- /// Load a profile from the repository
- pub fn load(repository: Repository, key: IPNSHash) -> Result<Self, Error> {
- Ok(UserProfile {
- profile: Profile::load(repository, key)?,
- })
- }
-
-}