diff options
Diffstat (limited to 'ipfs-api/examples/replace_config.rs')
-rw-r--r-- | ipfs-api/examples/replace_config.rs | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/ipfs-api/examples/replace_config.rs b/ipfs-api/examples/replace_config.rs index 65d418e..76cc96f 100644 --- a/ipfs-api/examples/replace_config.rs +++ b/ipfs-api/examples/replace_config.rs @@ -6,26 +6,22 @@ // copied, modified, or distributed except according to those terms. // -use futures::Future; use ipfs_api::IpfsClient; use std::io::Cursor; -use tokio::runtime::current_thread::Runtime; // Creates an Ipfs client, and replaces the config file with the default one. // -fn main() { - println!("note: this must be run in the root of the project repository"); - println!("connecting to localhost:5001..."); +#[cfg_attr(feature = "actix", actix_rt::main)] +#[cfg_attr(feature = "hyper", tokio::main)] +async fn main() { + eprintln!("note: this must be run in the root of the project repository"); + eprintln!("connecting to localhost:5001..."); let client = IpfsClient::default(); let default_config = include_str!("default_config.json"); - let req = client - .config_replace(Cursor::new(default_config)) - .map(|_| println!("replaced file")) - .map_err(|e| println!("{}", e)); - Runtime::new() - .expect("tokio runtime") - .block_on(req) - .expect("successful response"); + match client.config_replace(Cursor::new(default_config)).await { + Ok(_) => eprintln!("replaced config file"), + Err(e) => eprintln!("error replacing config file: {}", e), + } } |