From 3563c5e97f56f900fb36db492cd987bf13319df2 Mon Sep 17 00:00:00 2001 From: Ferris Tseng Date: Sun, 26 Nov 2017 15:46:33 -0500 Subject: refactoring --- ipfs-api/src/client.rs | 16 ++++++++-------- ipfs-api/src/response/block.rs | 3 --- ipfs-api/src/response/cat.rs | 9 --------- ipfs-api/src/response/files.rs | 3 --- ipfs-api/src/response/get.rs | 9 --------- ipfs-api/src/response/mod.rs | 4 ---- ipfs-api/src/response/tar.rs | 3 --- 7 files changed, 8 insertions(+), 39 deletions(-) delete mode 100644 ipfs-api/src/response/cat.rs delete mode 100644 ipfs-api/src/response/get.rs diff --git a/ipfs-api/src/client.rs b/ipfs-api/src/client.rs index d45e510..4ec1b4b 100644 --- a/ipfs-api/src/client.rs +++ b/ipfs-api/src/client.rs @@ -256,7 +256,7 @@ impl IpfsClient { &self, req: &Req, form: Option, - ) -> AsyncStreamResponse> + ) -> AsyncStreamResponse where Req: ApiRequest + Serialize, { @@ -265,10 +265,10 @@ impl IpfsClient { .into_future() .flatten() .map(|res| { - let stream: Box, Error = _>> = match res.status() { + let stream: Box> = match res.status() { // If the server responded OK, the data can be streamed back. // - StatusCode::Ok => Box::new(res.body().map(|chunk| chunk.to_vec()).from_err()), + StatusCode::Ok => Box::new(res.body().map(|chunk| chunk).from_err()), // If the server responded with an error status code, the body // still needs to be read so an error can be built. This block will @@ -377,7 +377,7 @@ impl IpfsClient { /// Gets a raw IPFS block. /// #[inline] - pub fn block_get(&self, hash: &str) -> AsyncStreamResponse { + pub fn block_get(&self, hash: &str) -> AsyncStreamResponse { self.request_stream_bytes(&request::BlockGet { hash }, None) } @@ -433,7 +433,7 @@ impl IpfsClient { /// Returns the contents of an Ipfs object. /// #[inline] - pub fn cat(&self, path: &str) -> AsyncStreamResponse { + pub fn cat(&self, path: &str) -> AsyncStreamResponse { self.request_stream_bytes(&request::Cat { path }, None) } @@ -624,7 +624,7 @@ impl IpfsClient { /// Read a file in MFS. /// #[inline] - pub fn files_read(&self, path: &str) -> AsyncStreamResponse { + pub fn files_read(&self, path: &str) -> AsyncStreamResponse { self.request_stream_bytes(&request::FilesRead { path }, None) } @@ -697,7 +697,7 @@ impl IpfsClient { /// Download Ipfs object. /// #[inline] - pub fn get(&self, path: &str) -> AsyncStreamResponse { + pub fn get(&self, path: &str) -> AsyncStreamResponse { self.request_stream_bytes(&request::Get { path }, None) } @@ -933,7 +933,7 @@ impl IpfsClient { /// Export a tar file from Ipfs. /// #[inline] - pub fn tar_cat(&self, path: &str) -> AsyncStreamResponse { + pub fn tar_cat(&self, path: &str) -> AsyncStreamResponse { self.request_stream_bytes(&request::TarCat { path }, None) } diff --git a/ipfs-api/src/response/block.rs b/ipfs-api/src/response/block.rs index f1a816e..d1e446a 100644 --- a/ipfs-api/src/response/block.rs +++ b/ipfs-api/src/response/block.rs @@ -6,9 +6,6 @@ // copied, modified, or distributed except according to those terms. // -pub type BlockGetResponse = Vec; - - #[derive(Debug, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct BlockPutResponse { diff --git a/ipfs-api/src/response/cat.rs b/ipfs-api/src/response/cat.rs deleted file mode 100644 index 2c8f207..0000000 --- a/ipfs-api/src/response/cat.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2017 rust-ipfs-api Developers -// -// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be -// copied, modified, or distributed except according to those terms. -// - -pub type CatResponse = Vec; diff --git a/ipfs-api/src/response/files.rs b/ipfs-api/src/response/files.rs index 23223e7..c0adbfb 100644 --- a/ipfs-api/src/response/files.rs +++ b/ipfs-api/src/response/files.rs @@ -41,9 +41,6 @@ pub type FilesMkdirResponse = (); pub type FilesMvResponse = (); -pub type FilesReadResponse = Vec; - - pub type FilesRmResponse = (); diff --git a/ipfs-api/src/response/get.rs b/ipfs-api/src/response/get.rs deleted file mode 100644 index ff04447..0000000 --- a/ipfs-api/src/response/get.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2017 rust-ipfs-api Developers -// -// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be -// copied, modified, or distributed except according to those terms. -// - -pub type GetResponse = Vec; diff --git a/ipfs-api/src/response/mod.rs b/ipfs-api/src/response/mod.rs index 196a2a7..2f3872f 100644 --- a/ipfs-api/src/response/mod.rs +++ b/ipfs-api/src/response/mod.rs @@ -10,7 +10,6 @@ pub use self::add::*; pub use self::bitswap::*; pub use self::block::*; pub use self::bootstrap::*; -pub use self::cat::*; pub use self::commands::*; pub use self::config::*; pub use self::dag::*; @@ -21,7 +20,6 @@ pub use self::error::*; pub use self::file::*; pub use self::files::*; pub use self::filestore::*; -pub use self::get::*; pub use self::id::*; pub use self::key::*; pub use self::log::*; @@ -63,7 +61,6 @@ mod add; mod bitswap; mod block; mod bootstrap; -mod cat; mod commands; mod config; mod dag; @@ -74,7 +71,6 @@ mod error; mod file; mod files; mod filestore; -mod get; mod id; mod key; mod log; diff --git a/ipfs-api/src/response/tar.rs b/ipfs-api/src/response/tar.rs index f19cfb8..bb78d37 100644 --- a/ipfs-api/src/response/tar.rs +++ b/ipfs-api/src/response/tar.rs @@ -14,9 +14,6 @@ pub struct TarAddResponse { } -pub type TarCatResponse = Vec; - - #[cfg(test)] mod tests { deserialize_test!(v0_tar_add_0, TarAddResponse); -- cgit v1.2.3