summaryrefslogtreecommitdiffstats
path: root/ipfs-api/examples/get_commands.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ipfs-api/examples/get_commands.rs')
-rw-r--r--ipfs-api/examples/get_commands.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/ipfs-api/examples/get_commands.rs b/ipfs-api/examples/get_commands.rs
index d3f9852..b12ffa1 100644
--- a/ipfs-api/examples/get_commands.rs
+++ b/ipfs-api/examples/get_commands.rs
@@ -6,11 +6,12 @@
// copied, modified, or distributed except according to those terms.
//
+extern crate futures;
+extern crate hyper;
extern crate ipfs_api;
-extern crate tokio_core;
+use futures::Future;
use ipfs_api::{response, IpfsClient};
-use tokio_core::reactor::Core;
fn print_recursive(indent: usize, cmd: &response::CommandsResponse) {
let cmd_indent = " ".repeat(indent * 4);
@@ -39,9 +40,11 @@ fn print_recursive(indent: usize, cmd: &response::CommandsResponse) {
fn main() {
println!("connecting to localhost:5001...");
- let mut core = Core::new().expect("expected event loop");
- let client = IpfsClient::default(&core.handle());
- let req = client.commands();
+ let client = IpfsClient::default();
+ let req = client
+ .commands()
+ .map(|commands| print_recursive(0, &commands))
+ .map_err(|e| eprintln!("{}", e));
- print_recursive(0, &core.run(req).expect("expected a valid response"));
+ hyper::rt::run(req);
}