summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFerris Tseng <ferristseng@fastmail.fm>2017-11-26 15:46:33 -0500
committerFerris Tseng <ferristseng@fastmail.fm>2017-11-26 15:46:33 -0500
commit3563c5e97f56f900fb36db492cd987bf13319df2 (patch)
tree053fe9173f134bdf358c72539810137eb2dd8406
parentef2e05804063e3f9696b3996d01f9e500741c04f (diff)
refactoring
-rw-r--r--ipfs-api/src/client.rs16
-rw-r--r--ipfs-api/src/response/block.rs3
-rw-r--r--ipfs-api/src/response/cat.rs9
-rw-r--r--ipfs-api/src/response/files.rs3
-rw-r--r--ipfs-api/src/response/get.rs9
-rw-r--r--ipfs-api/src/response/mod.rs4
-rw-r--r--ipfs-api/src/response/tar.rs3
7 files changed, 8 insertions, 39 deletions
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<multipart::Form>,
- ) -> AsyncStreamResponse<Vec<u8>>
+ ) -> AsyncStreamResponse<Chunk>
where
Req: ApiRequest + Serialize,
{
@@ -265,10 +265,10 @@ impl IpfsClient {
.into_future()
.flatten()
.map(|res| {
- let stream: Box<Stream<Item = Vec<u8>, Error = _>> = match res.status() {
+ let stream: Box<Stream<Item = Chunk, Error = _>> = 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<response::BlockGetResponse> {
+ pub fn block_get(&self, hash: &str) -> AsyncStreamResponse<Chunk> {
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<response::CatResponse> {
+ pub fn cat(&self, path: &str) -> AsyncStreamResponse<Chunk> {
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<response::FilesReadResponse> {
+ pub fn files_read(&self, path: &str) -> AsyncStreamResponse<Chunk> {
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<response::GetResponse> {
+ pub fn get(&self, path: &str) -> AsyncStreamResponse<Chunk> {
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<response::TarCatResponse> {
+ pub fn tar_cat(&self, path: &str) -> AsyncStreamResponse<Chunk> {
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<u8>;
-
-
#[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, <LICENSE-APACHE or
-// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
-// http://opensource.org/licenses/MIT>, at your option. This file may not be
-// copied, modified, or distributed except according to those terms.
-//
-
-pub type CatResponse = Vec<u8>;
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<u8>;
-
-
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, <LICENSE-APACHE or
-// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
-// http://opensource.org/licenses/MIT>, at your option. This file may not be
-// copied, modified, or distributed except according to those terms.
-//
-
-pub type GetResponse = Vec<u8>;
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<u8>;
-
-
#[cfg(test)]
mod tests {
deserialize_test!(v0_tar_add_0, TarAddResponse);