summaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md39
1 files changed, 23 insertions, 16 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