diff options
author | Ferris Tseng <ferristseng@fastmail.fm> | 2017-10-12 20:34:35 -0400 |
---|---|---|
committer | Ferris Tseng <ferristseng@fastmail.fm> | 2017-10-12 20:34:35 -0400 |
commit | d8e0af6e5c2f4c37763ed9e22adae6b2ce2bd016 (patch) | |
tree | fa15ce64edade2bf6814388051a8fd885efa545b /ipfs-api/examples/add_file.rs | |
parent | 31ac8fcce3e34c0a5fa7c96f952523d3c643585f (diff) |
refactor examples; add pubsub example
Diffstat (limited to 'ipfs-api/examples/add_file.rs')
-rw-r--r-- | ipfs-api/examples/add_file.rs | 21 |
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); } |