From 0e5f09b2bd05690f3d28f7076629031fcc2cc6e6 Mon Sep 17 00:00:00 2001
From: cel 🌸 <cel@bunny.garden>
Date: Thu, 2 Jan 2025 17:48:12 +0000
Subject: WIP: client

---
 stanza/src/client/iq.rs | 6 ++++++
 stanza/src/roster.rs    | 7 ++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

(limited to 'stanza')

diff --git a/stanza/src/client/iq.rs b/stanza/src/client/iq.rs
index 6ee80ea..2e87636 100644
--- a/stanza/src/client/iq.rs
+++ b/stanza/src/client/iq.rs
@@ -9,6 +9,7 @@ use peanuts::{
 use crate::{
     bind::{self, Bind},
     client::error::Error,
+    roster,
     xep_0199::{self, Ping},
 };
 
@@ -31,6 +32,7 @@ pub struct Iq {
 pub enum Query {
     Bind(Bind),
     Ping(Ping),
+    Roster(roster::Query),
     Unsupported,
 }
 
@@ -39,6 +41,9 @@ impl FromElement for Query {
         match element.identify() {
             (Some(bind::XMLNS), "bind") => Ok(Query::Bind(Bind::from_element(element)?)),
             (Some(xep_0199::XMLNS), "ping") => Ok(Query::Ping(Ping::from_element(element)?)),
+            (Some(roster::XMLNS), "query") => {
+                Ok(Query::Roster(roster::Query::from_element(element)?))
+            }
             _ => Ok(Query::Unsupported),
         }
     }
@@ -49,6 +54,7 @@ impl IntoElement for Query {
         match self {
             Query::Bind(bind) => bind.builder(),
             Query::Ping(ping) => ping.builder(),
+            Query::Roster(query) => query.builder(),
             // TODO: consider what to do if attempt to serialize unsupported
             Query::Unsupported => todo!(),
         }
diff --git a/stanza/src/roster.rs b/stanza/src/roster.rs
index b49fcc3..9209fad 100644
--- a/stanza/src/roster.rs
+++ b/stanza/src/roster.rs
@@ -8,6 +8,7 @@ use peanuts::{
 
 pub const XMLNS: &str = "jabber:iq:roster";
 
+#[derive(Debug, Clone)]
 pub struct Query {
     ver: Option<String>,
     items: Vec<Item>,
@@ -33,7 +34,7 @@ impl IntoElement for Query {
     }
 }
 
-#[derive(Clone)]
+#[derive(Clone, Debug)]
 pub struct Item {
     approved: Option<bool>,
     ask: bool,
@@ -95,7 +96,7 @@ impl IntoElement for Item {
     }
 }
 
-#[derive(Default, Clone, Copy)]
+#[derive(Default, Clone, Copy, Debug)]
 pub enum Subscription {
     Both,
     From,
@@ -132,7 +133,7 @@ impl ToString for Subscription {
     }
 }
 
-#[derive(Clone)]
+#[derive(Clone, Debug)]
 pub struct Group(Option<String>);
 
 impl FromElement for Group {
-- 
cgit