From 648517312fd0aa754c938abde66af038e2628c13 Mon Sep 17 00:00:00 2001 From: Ferris Tseng Date: Tue, 23 Jan 2018 20:49:08 -0500 Subject: add /object/new and /object/data --- ipfs-api/src/client.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'ipfs-api/src/client.rs') diff --git a/ipfs-api/src/client.rs b/ipfs-api/src/client.rs index 7a4fbed..5b02f95 100644 --- a/ipfs-api/src/client.rs +++ b/ipfs-api/src/client.rs @@ -1654,7 +1654,26 @@ impl IpfsClient { ) } - // TODO /object/data + /// Output the raw bytes of an Ipfs object. + /// + /// ```no_run + /// # extern crate ipfs_api; + /// # extern crate tokio_core; + /// # + /// use ipfs_api::IpfsClient; + /// use tokio_core::reactor::Core; + /// + /// # fn main() { + /// let mut core = Core::new().unwrap(); + /// let client = IpfsClient::default(&core.handle()); + /// let req = client.object_data("/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY"); + /// # } + /// ``` + /// + #[inline] + pub fn object_data(&self, key: &str) -> AsyncStreamResponse { + self.request_stream_bytes(&request::ObjectData { key }, None) + } /// Returns the diff of two Ipfs objects. /// @@ -1725,7 +1744,30 @@ impl IpfsClient { self.request(&request::ObjectLinks { key }, None) } - // TODO /object/new + /// Create a new object. + /// + /// ```no_run + /// # extern crate ipfs_api; + /// # extern crate tokio_core; + /// # + /// use ipfs_api::{IpfsClient, ObjectTemplate}; + /// use tokio_core::reactor::Core; + /// + /// # fn main() { + /// let mut core = Core::new().unwrap(); + /// let client = IpfsClient::default(&core.handle()); + /// let req = client.object_new(None); + /// let req = client.object_new(Some(ObjectTemplate::UnixFsDir)); + /// # } + /// ``` + /// + #[inline] + pub fn object_new( + &self, + template: Option, + ) -> AsyncResponse { + self.request(&request::ObjectNew { template }, None) + } // TODO /object/patch/add-link -- cgit v1.2.3