summaryrefslogtreecommitdiffstats
path: root/ipfs-api/examples/get_version.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ipfs-api/examples/get_version.rs')
-rw-r--r--ipfs-api/examples/get_version.rs21
1 files changed, 8 insertions, 13 deletions
diff --git a/ipfs-api/examples/get_version.rs b/ipfs-api/examples/get_version.rs
index 992f249..9d22988 100644
--- a/ipfs-api/examples/get_version.rs
+++ b/ipfs-api/examples/get_version.rs
@@ -6,24 +6,19 @@
// copied, modified, or distributed except according to those terms.
//
-use futures::Future;
use ipfs_api::IpfsClient;
-use tokio::runtime::current_thread::Runtime;
// Creates an Ipfs client, and gets the version of the Ipfs server.
//
-fn main() {
- println!("connecting to localhost:5001...");
+#[cfg_attr(feature = "actix", actix_rt::main)]
+#[cfg_attr(feature = "hyper", tokio::main)]
+async fn main() {
+ eprintln!("connecting to localhost:5001...");
let client = IpfsClient::default();
- let req = client
- .version()
- .map(|version| println!("version: {:?}", version.version));
- let fut = req.map_err(|e| eprintln!("{}", e));
-
- Runtime::new()
- .expect("tokio runtime")
- .block_on(fut)
- .expect("successful response");
+ match client.version().await {
+ Ok(version) => eprintln!("version: {:?}", version.version),
+ Err(e) => eprintln!("error getting version: {}", e),
+ }
}