From d08138ea633da76d9ca390e4f9e3c5489aee23d1 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 5 Jul 2021 22:03:47 +0200 Subject: Update reqwest and make async. This means adding the full tokio as a dependency. While there isn't much gain to going async in the current cli demo app, a full fledged app may have more to gain by it. First foray into async rust, so I might not do it right... --- src/bin/zot/main.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/bin/zot/main.rs') diff --git a/src/bin/zot/main.rs b/src/bin/zot/main.rs index 5828f44..09fdd61 100644 --- a/src/bin/zot/main.rs +++ b/src/bin/zot/main.rs @@ -22,7 +22,8 @@ use std::str::FromStr; mod zot; -fn main() { +#[tokio::main] +async fn main() { dotenv().ok(); let site = env::var("HZ_SITE").expect("SITE variable expected"); let user = env::var("HZ_USER").expect("USER variable expected"); @@ -79,24 +80,25 @@ fn main() { match matches.subcommand() { ("channel", Some(m)) => { let raw = m.is_present("raw"); - zot::channel_stream::fetch(&client, raw); + zot::channel_stream::fetch(&client, raw).await; } ("network", Some(m)) => { let raw = m.is_present("raw"); - zot::network_stream::fetch(&client, raw); + zot::network_stream::fetch(&client, raw).await; } ("abconfig", _) => { - zot::abconfig::fetch(&client); + zot::abconfig::fetch(&client).await; } ("abook", Some(m)) => { let raw = m.is_present("raw"); - zot::abook::fetch(&client, raw); + zot::abook::fetch(&client, raw).await; } ("group", Some(m)) => { if let Some(id) = m.value_of("ID") { let res = zotapi::group_members() .by_group_id(u64::from_str(id).unwrap()) .fetch(&client) + .await .unwrap(); if m.is_present("raw") { @@ -108,6 +110,7 @@ fn main() { let res = zotapi::group_members() .by_group_name(gname) .fetch(&client) + .await .unwrap(); if m.is_present("raw") { @@ -116,7 +119,7 @@ fn main() { zot::group::list_members(&res); } } else { - let res = zotapi::group().fetch(&client).unwrap(); + let res = zotapi::group().fetch(&client).await.unwrap(); if m.is_present("raw") { println!("{}", res); @@ -135,10 +138,10 @@ fn main() { zot::xchan::Type::Addr }; - zot::xchan::fetch(&client, raw, t, m.value_of("ID").unwrap()); + zot::xchan::fetch(&client, raw, t, m.value_of("ID").unwrap()).await; } ("post", Some(m)) => { - zot::item::post(&client, m); + zot::item::post(&client, m).await; } _ => { println!("{}", matches.usage()); -- cgit v1.2.3