From fedf875de04c8577a439bff9f62f1cb7d079459a Mon Sep 17 00:00:00 2001 From: Ferris Tseng Date: Wed, 27 Jun 2018 18:12:36 -0400 Subject: updating version number in docs and README --- README.md | 39 +++++++++++++++++++++++---------------- ipfs-api/src/lib.rs | 2 +- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 3218b82..d5020ac 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Rust library for connecting to the IPFS HTTP API using tokio. ```toml [dependencies] -ipfs-api = "0.4.0-alpha.3" +ipfs-api = "0.5.0-alpha1" ``` ### Examples @@ -19,38 +19,45 @@ Write a file to IPFS: ```rust # +use hyper::rt::Future; use ipfs_api::IpfsClient; use std::io::Cursor; -use tokio_core::reactor::Core; -let mut core = Core::new().unwrap(); -let client = IpfsClient::default(&core.handle()); +let client = IpfsClient::default(); let data = Cursor::new("Hello World!"); -let req = client.add(data); -let res = core.run(req).unwrap(); +let req = client + .add(data) + .map(|res| { + println!("{}", res.hash); + }) + .map_err(|e| eprintln!("{}", e)); -println!("{}", res.hash); +hyper::rt::run(req); ``` Read a file from IPFS: ```rust # -use futures::stream::Stream; +use futures::{Future, Stream}; use ipfs_api::IpfsClient; use std::io::{self, Write}; -use tokio_core::reactor::Core; -let mut core = Core::new().unwrap(); -let client = IpfsClient::default(&core.handle()); +let client = IpfsClient::default(); -let req = client.get("/test/file.json").concat2(); -let res = core.run(req).unwrap(); -let out = io::stdout(); -let mut out = out.lock(); +let req = client + .get("/test/file.json") + .concat2() + .map(|res| { + let out = io::stdout(); + let mut out = out.lock(); -out.write_all(&res).unwrap(); + out.write_all(&res).unwrap(); + }) + .map_err(|e| eprintln!("{}", e)); + +hyper::rt::run(req); ``` There are also a bunch of examples included in the project, which diff --git a/ipfs-api/src/lib.rs b/ipfs-api/src/lib.rs index 284350f..05fe0fa 100644 --- a/ipfs-api/src/lib.rs +++ b/ipfs-api/src/lib.rs @@ -14,7 +14,7 @@ //! //! ```toml //! [dependencies] -//! ipfs-api = "0.4.0-alpha.3" +//! ipfs-api = "0.5.0-alpha1" //! ``` //! //! ## Examples -- cgit v1.2.3