aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/zot/main.rs
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-07-05 22:03:47 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-07-05 22:03:47 +0200
commitd08138ea633da76d9ca390e4f9e3c5489aee23d1 (patch)
tree80a682350c75d6e01f05144cf054e9d48edbed07 /src/bin/zot/main.rs
parent098adf3a6895529bbd467f13b55fc241099c2ff7 (diff)
downloadrust-zotapi-d08138ea633da76d9ca390e4f9e3c5489aee23d1.tar.gz
rust-zotapi-d08138ea633da76d9ca390e4f9e3c5489aee23d1.tar.bz2
rust-zotapi-d08138ea633da76d9ca390e4f9e3c5489aee23d1.zip
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...
Diffstat (limited to 'src/bin/zot/main.rs')
-rw-r--r--src/bin/zot/main.rs19
1 files changed, 11 insertions, 8 deletions
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());