summaryrefslogtreecommitdiffstats
path: root/ipfs-api/examples/add_file.rs
diff options
context:
space:
mode:
authorFerris Tseng <ferristseng@fastmail.fm>2017-10-12 20:34:35 -0400
committerFerris Tseng <ferristseng@fastmail.fm>2017-10-12 20:34:35 -0400
commitd8e0af6e5c2f4c37763ed9e22adae6b2ce2bd016 (patch)
treefa15ce64edade2bf6814388051a8fd885efa545b /ipfs-api/examples/add_file.rs
parent31ac8fcce3e34c0a5fa7c96f952523d3c643585f (diff)
refactor examples; add pubsub example
Diffstat (limited to 'ipfs-api/examples/add_file.rs')
-rw-r--r--ipfs-api/examples/add_file.rs21
1 files changed, 8 insertions, 13 deletions
diff --git a/ipfs-api/examples/add_file.rs b/ipfs-api/examples/add_file.rs
index 2dccfa9..da991cf 100644
--- a/ipfs-api/examples/add_file.rs
+++ b/ipfs-api/examples/add_file.rs
@@ -5,22 +5,17 @@ use ipfs_api::IpfsClient;
use std::fs::File;
use tokio_core::reactor::Core;
-
// Creates an Ipfs client, and adds this source file to Ipfs.
//
fn main() {
- if let Ok(mut core) = Core::new() {
- println!("note: this must be run in the root of the project repository");
- println!("connecting to localhost:5001...");
+ println!("note: this must be run in the root of the project repository");
+ println!("connecting to localhost:5001...");
- let client =
- IpfsClient::new(&core.handle(), "localhost", 5001).expect("expected a valid url");
- let file = File::open(file!()).expect("could not read source file");
- let req = client.add(file);
- let add = core.run(req).expect("expected a valid response");
+ let mut core = Core::new().expect("expected event loop");
+ let client = IpfsClient::default(&core.handle());
+ let file = File::open(file!()).expect("could not read source file");
+ let req = client.add(file);
+ let add = core.run(req).expect("expected a valid response");
- println!("added file: {:?}", add);
- } else {
- println!("failed to create event loop");
- }
+ println!("added file: {:?}", add);
}