aboutsummaryrefslogtreecommitdiffstats
path: root/examples/zot/abook.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/zot/abook.rs')
-rw-r--r--examples/zot/abook.rs29
1 files changed, 5 insertions, 24 deletions
diff --git a/examples/zot/abook.rs b/examples/zot/abook.rs
index b710fa7..97025c3 100644
--- a/examples/zot/abook.rs
+++ b/examples/zot/abook.rs
@@ -15,13 +15,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-pub fn fetch(client: &zotapi::Client, raw: bool) {
- match zotapi::abook().fetch(&client) {
- Ok(payload) => {
- if raw {
- println!("{}", &payload);
- } else {
- process(&payload);
+pub fn fetch(client: &zotapi::Client, _raw: bool) {
+ match zotapi::Abook::z().fetch(&client) {
+ Ok(abooks) => {
+ for b in abooks {
+ println!("{:?}", b);
}
}
Err(e) => {
@@ -29,20 +27,3 @@ pub fn fetch(client: &zotapi::Client, raw: bool) {
}
}
}
-
-fn process(payload: &str) {
- let data: serde_json::Value = serde_json::from_str(&payload).unwrap();
- match data {
- serde_json::Value::Array(v) => {
- for contact in v {
- println!(
- "{} ({}, {})",
- contact["xchan_name"], contact["xchan_addr"], contact["xchan_network"]
- );
- }
- }
- _ => {
- println!("Unexpected data:\n{}", payload);
- }
- };
-}