diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2019-06-15 19:25:10 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2019-06-15 19:25:10 +0200 |
commit | fcd4d64287ef176b0f2167e29f8b32b188e21e9d (patch) | |
tree | e6930557cb311432274a2b5b8e352897aef187ad | |
parent | 8739e1b7f0e422f0b0c8a146fa5ad302af831dff (diff) |
More Repository functionality
-rw-r--r-- | src/repository/repository.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/repository/repository.rs b/src/repository/repository.rs index 7381176..5ed1244 100644 --- a/src/repository/repository.rs +++ b/src/repository/repository.rs @@ -19,9 +19,15 @@ use crate::types::content::Content; use crate::types::content::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(Clone)] pub struct Repository(TypedClientFassade); @@ -30,4 +36,29 @@ impl Repository { TypedClientFassade::new(host, port).map(Repository) } + pub fn get_block<H>(&self, hash: H) -> impl Future<Item = Block, Error = Error> + where H: AsRef<IPFSHash> + { + self.0.get(hash) + } + + pub fn put_block<B>(&self, b: B) -> impl Future<Item = IPFSHash, Error = Error> + where B: AsRef<Block> + { + self.0.put(b.as_ref()) + } + + pub fn get_content<H>(&self, hash: H) -> impl Future<Item = Content, Error = Error> + where H: AsRef<IPFSHash> + { + self.0.get(hash) + } + + pub fn put_content<C>(&self, c: C) -> impl Future<Item = IPFSHash, Error = Error> + where C: AsRef<Content> + { + self.0.put(c.as_ref()) + } + } + |