diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-04-28 21:01:26 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-04-28 21:22:54 +0200 |
commit | 542defd29c7d153a4268bba8a81319af0bb787c3 (patch) | |
tree | d0ad52781876903e91f2e2689a6367979d093a65 /src/repository/repository.rs | |
parent | 1b5c13abf7b944f0f03a9bfd41b2ddf2afe14382 (diff) |
Simplify Repository interface by implementing dereferencing
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/repository/repository.rs')
-rw-r--r-- | src/repository/repository.rs | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/repository/repository.rs b/src/repository/repository.rs index 35c83a2..85dca8d 100644 --- a/src/repository/repository.rs +++ b/src/repository/repository.rs @@ -31,43 +31,41 @@ use crate::repository::client::TypedClientFassade; #[derive(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<Repository, Error> { TypedClientFassade::new(host, port).map(Repository) } - pub async fn get_raw_bytes<H>(&self, hash: H) -> Result<Vec<u8>, Error> - where H: AsRef<IPFSHash> - { - self.0.get_raw_bytes(hash).await - } - pub async fn get_block<H>(&self, hash: H) -> Result<Block, Error> where H: AsRef<IPFSHash> { - self.0.get(hash).await + self.0.get_typed(hash).await } pub async fn put_block<B>(&self, b: B) -> Result<IPFSHash, Error> where B: AsRef<Block> { - self.0.put(b.as_ref()).await + self.0.put_typed(b.as_ref()).await } pub async fn get_content<H>(&self, hash: H) -> Result<Content, Error> where H: AsRef<IPFSHash> { - self.0.get(hash).await + self.0.get_typed(hash).await } pub async fn put_content<C>(&self, c: C) -> Result<IPFSHash, Error> where C: AsRef<Content> { - self.0.put(c.as_ref()).await - } - - pub async fn publish(&self, key: &str, hash: &str) -> Result<IPNSHash, Error> { - self.0.publish(key, hash).await + self.0.put_typed(c.as_ref()).await } } |