aboutsummaryrefslogtreecommitdiffstats
path: root/examples/zot/abook.rs
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2020-02-14 15:00:27 +0100
committerHarald Eilertsen <haraldei@anduin.net>2020-02-14 15:15:10 +0100
commitcd83b0f4c30f21d23bc9046a73c7058c450007e3 (patch)
treef37eb9c94d6d6b9ae064f7a978009af43b710595 /examples/zot/abook.rs
parent036fd6b2ea078205f625595cd481cdead307e79d (diff)
downloadrust-zotapi-cd83b0f4c30f21d23bc9046a73c7058c450007e3.tar.gz
rust-zotapi-cd83b0f4c30f21d23bc9046a73c7058c450007e3.tar.bz2
rust-zotapi-cd83b0f4c30f21d23bc9046a73c7058c450007e3.zip
Update abook with struct and request object.
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);
- }
- };
-}