diff options
author | Ferris Tseng <ferristseng@fastmail.fm> | 2017-11-02 12:33:27 -0400 |
---|---|---|
committer | Ferris Tseng <ferristseng@fastmail.fm> | 2017-11-02 12:33:27 -0400 |
commit | f6b594b9ada9396cebdd3d8d4cb37c86d6198301 (patch) | |
tree | 1a27bb3bf270f18592bee5117abd102bea34978d | |
parent | 07f9bac5a02e8d430e6b0549f24169c0b5a8933a (diff) |
implement get command
-rw-r--r-- | ipfs-api/src/client.rs | 7 | ||||
-rw-r--r-- | ipfs-api/src/request/get.rs | 23 | ||||
-rw-r--r-- | ipfs-api/src/request/mod.rs | 2 |
3 files changed, 32 insertions, 0 deletions
diff --git a/ipfs-api/src/client.rs b/ipfs-api/src/client.rs index 09e30b3..6a22f07 100644 --- a/ipfs-api/src/client.rs +++ b/ipfs-api/src/client.rs @@ -599,6 +599,13 @@ impl IpfsClient { self.request_stream(&request::FilestoreVerify) } + /// Download Ipfs object. + /// + #[inline] + pub fn get(&self, path: &str) -> AsyncResponse<response::GetResponse> { + self.request_bytes(&request::Get { path }) + } + /// List the contents of an Ipfs multihash. /// #[inline] diff --git a/ipfs-api/src/request/get.rs b/ipfs-api/src/request/get.rs new file mode 100644 index 0000000..c33bd4b --- /dev/null +++ b/ipfs-api/src/request/get.rs @@ -0,0 +1,23 @@ +// 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. +// + +use request::ApiRequest; + + +#[derive(Serialize)] +pub struct Get<'a> { + #[serde(rename = "arg")] + pub path: &'a str, +} + +impl<'a> ApiRequest for Get<'a> { + #[inline] + fn path() -> &'static str { + "/get" + } +} diff --git a/ipfs-api/src/request/mod.rs b/ipfs-api/src/request/mod.rs index 96c2b63..438c6c2 100644 --- a/ipfs-api/src/request/mod.rs +++ b/ipfs-api/src/request/mod.rs @@ -20,6 +20,7 @@ pub use self::dns::*; pub use self::file::*; pub use self::files::*; pub use self::filestore::*; +pub use self::get::*; pub use self::ls::*; pub use self::object::*; pub use self::pin::*; @@ -79,6 +80,7 @@ mod dns; mod file; mod files; mod filestore; +mod get; mod ls; mod object; mod pin; |