aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/zot/main.rs19
-rw-r--r--src/bin/zot/zot/abconfig.rs4
-rw-r--r--src/bin/zot/zot/abook.rs4
-rw-r--r--src/bin/zot/zot/channel_stream.rs4
-rw-r--r--src/bin/zot/zot/item.rs4
-rw-r--r--src/bin/zot/zot/network_stream.rs4
-rw-r--r--src/bin/zot/zot/xchan.rs8
7 files changed, 25 insertions, 22 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());
diff --git a/src/bin/zot/zot/abconfig.rs b/src/bin/zot/zot/abconfig.rs
index 2e357e4..14875c8 100644
--- a/src/bin/zot/zot/abconfig.rs
+++ b/src/bin/zot/zot/abconfig.rs
@@ -17,8 +17,8 @@
use zotapi;
-pub fn fetch(client: &zotapi::Client) {
- match zotapi::ABConfig::z().fetch(&client) {
+pub async fn fetch(client: &zotapi::Client) {
+ match zotapi::ABConfig::z().fetch(&client).await {
Ok(v) => {
println!("Id: Chan: Cat: Key: Val: xchan:");
for entry in v {
diff --git a/src/bin/zot/zot/abook.rs b/src/bin/zot/zot/abook.rs
index 97025c3..6c33757 100644
--- a/src/bin/zot/zot/abook.rs
+++ b/src/bin/zot/zot/abook.rs
@@ -15,8 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-pub fn fetch(client: &zotapi::Client, _raw: bool) {
- match zotapi::Abook::z().fetch(&client) {
+pub async fn fetch(client: &zotapi::Client, _raw: bool) {
+ match zotapi::Abook::z().fetch(&client).await {
Ok(abooks) => {
for b in abooks {
println!("{:?}", b);
diff --git a/src/bin/zot/zot/channel_stream.rs b/src/bin/zot/zot/channel_stream.rs
index 33ad7cf..68a5402 100644
--- a/src/bin/zot/zot/channel_stream.rs
+++ b/src/bin/zot/zot/channel_stream.rs
@@ -20,8 +20,8 @@ use zotapi;
use serde_json;
use std::iter::Iterator;
-pub fn fetch(client: &zotapi::Client, raw: bool) {
- match zotapi::channel_stream().fetch(&client) {
+pub async fn fetch(client: &zotapi::Client, raw: bool) {
+ match zotapi::channel_stream().fetch(&client).await {
Ok(payload) => {
if raw {
println!("{}", payload);
diff --git a/src/bin/zot/zot/item.rs b/src/bin/zot/zot/item.rs
index 648a9f0..dbb39ba 100644
--- a/src/bin/zot/zot/item.rs
+++ b/src/bin/zot/zot/item.rs
@@ -18,7 +18,7 @@
use clap::ArgMatches;
use zotapi;
-pub fn post(client: &zotapi::Client, args: &ArgMatches) {
+pub async fn post(client: &zotapi::Client, args: &ArgMatches<'_>) {
let mut msg = zotapi::item();
let body: String;
@@ -42,7 +42,7 @@ pub fn post(client: &zotapi::Client, args: &ArgMatches) {
}
}
- match msg.create(&client) {
+ match msg.create(&client).await {
Ok(res) => {
if res.success {
println!("New item with id {} posted successfully!", res.item_id);
diff --git a/src/bin/zot/zot/network_stream.rs b/src/bin/zot/zot/network_stream.rs
index 0e6edb4..a5a7142 100644
--- a/src/bin/zot/zot/network_stream.rs
+++ b/src/bin/zot/zot/network_stream.rs
@@ -20,8 +20,8 @@ use zotapi;
use serde_json;
use std::iter::Iterator;
-pub fn fetch(client: &zotapi::Client, raw: bool) {
- match zotapi::network_stream().fetch(&client) {
+pub async fn fetch(client: &zotapi::Client, raw: bool) {
+ match zotapi::network_stream().fetch(&client).await {
Ok(payload) => {
if raw {
println!("{}", payload);
diff --git a/src/bin/zot/zot/xchan.rs b/src/bin/zot/zot/xchan.rs
index 088d49c..146b2ab 100644
--- a/src/bin/zot/zot/xchan.rs
+++ b/src/bin/zot/zot/xchan.rs
@@ -23,11 +23,11 @@ pub enum Type {
GUID,
}
-pub fn fetch(client: &zotapi::Client, _raw: bool, t: Type, id: &str) {
+pub async fn fetch(client: &zotapi::Client, _raw: bool, t: Type, id: &str) {
let res = match t {
- Type::Addr => zotapi::XChan::z().by_address(&id).fetch(&client),
- Type::Hash => zotapi::XChan::z().by_hash(&id).fetch(&client),
- Type::GUID => zotapi::XChan::z().by_guid(&id).fetch(&client),
+ Type::Addr => zotapi::XChan::z().by_address(&id).fetch(&client).await,
+ Type::Hash => zotapi::XChan::z().by_hash(&id).fetch(&client).await,
+ Type::GUID => zotapi::XChan::z().by_guid(&id).fetch(&client).await,
};
match res {