aboutsummaryrefslogtreecommitdiffstats
path: root/stanza/src/client
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2024-12-22 18:58:28 +0000
committerLibravatar cel 🌸 <cel@bunny.garden>2024-12-22 18:58:28 +0000
commit6385e43e8ca467e53c6a705a932016c5af75c3a2 (patch)
treef63fb7bd9a349f24b093ba4dd037c6ce7789f5ee /stanza/src/client
parent595d165479b8b12e456f39205d8433b822b07487 (diff)
downloadluz-6385e43e8ca467e53c6a705a932016c5af75c3a2.tar.gz
luz-6385e43e8ca467e53c6a705a932016c5af75c3a2.tar.bz2
luz-6385e43e8ca467e53c6a705a932016c5af75c3a2.zip
implement sink and stream with tokio::spawn
Diffstat (limited to 'stanza/src/client')
-rw-r--r--stanza/src/client/iq.rs9
-rw-r--r--stanza/src/client/message.rs9
-rw-r--r--stanza/src/client/mod.rs1
-rw-r--r--stanza/src/client/presence.rs11
4 files changed, 19 insertions, 11 deletions
diff --git a/stanza/src/client/iq.rs b/stanza/src/client/iq.rs
index 388979e..6ee80ea 100644
--- a/stanza/src/client/iq.rs
+++ b/stanza/src/client/iq.rs
@@ -9,10 +9,12 @@ use peanuts::{
use crate::{
bind::{self, Bind},
client::error::Error,
+ xep_0199::{self, Ping},
};
use super::XMLNS;
+#[derive(Debug)]
pub struct Iq {
pub from: Option<JID>,
pub id: String,
@@ -25,9 +27,10 @@ pub struct Iq {
pub errors: Vec<Error>,
}
-#[derive(Clone)]
+#[derive(Clone, Debug)]
pub enum Query {
Bind(Bind),
+ Ping(Ping),
Unsupported,
}
@@ -35,6 +38,7 @@ impl FromElement for Query {
fn from_element(element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> {
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)?)),
_ => Ok(Query::Unsupported),
}
}
@@ -44,6 +48,7 @@ impl IntoElement for Query {
fn builder(&self) -> peanuts::element::ElementBuilder {
match self {
Query::Bind(bind) => bind.builder(),
+ Query::Ping(ping) => ping.builder(),
// TODO: consider what to do if attempt to serialize unsupported
Query::Unsupported => todo!(),
}
@@ -88,7 +93,7 @@ impl IntoElement for Iq {
}
}
-#[derive(Copy, Clone, PartialEq, Eq)]
+#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum IqType {
Error,
Get,
diff --git a/stanza/src/client/message.rs b/stanza/src/client/message.rs
index b9d995f..2337d7b 100644
--- a/stanza/src/client/message.rs
+++ b/stanza/src/client/message.rs
@@ -8,6 +8,7 @@ use peanuts::{
use super::XMLNS;
+#[derive(Debug)]
pub struct Message {
from: Option<JID>,
id: Option<String>,
@@ -69,7 +70,7 @@ impl IntoElement for Message {
}
}
-#[derive(Default, PartialEq, Eq, Copy, Clone)]
+#[derive(Default, PartialEq, Eq, Copy, Clone, Debug)]
pub enum MessageType {
Chat,
Error,
@@ -106,7 +107,7 @@ impl ToString for MessageType {
}
}
-#[derive(Clone)]
+#[derive(Clone, Debug)]
pub struct Body {
lang: Option<String>,
body: Option<String>,
@@ -132,7 +133,7 @@ impl IntoElement for Body {
}
}
-#[derive(Clone)]
+#[derive(Clone, Debug)]
pub struct Subject {
lang: Option<String>,
subject: Option<String>,
@@ -158,7 +159,7 @@ impl IntoElement for Subject {
}
}
-#[derive(Clone)]
+#[derive(Clone, Debug)]
pub struct Thread {
parent: Option<String>,
thread: Option<String>,
diff --git a/stanza/src/client/mod.rs b/stanza/src/client/mod.rs
index 2b063d6..e9c336e 100644
--- a/stanza/src/client/mod.rs
+++ b/stanza/src/client/mod.rs
@@ -15,6 +15,7 @@ pub mod presence;
pub const XMLNS: &str = "jabber:client";
+#[derive(Debug)]
pub enum Stanza {
Message(Message),
Presence(Presence),
diff --git a/stanza/src/client/presence.rs b/stanza/src/client/presence.rs
index dd14bff..5354966 100644
--- a/stanza/src/client/presence.rs
+++ b/stanza/src/client/presence.rs
@@ -8,6 +8,7 @@ use peanuts::{
use super::{error::Error, XMLNS};
+#[derive(Debug)]
pub struct Presence {
from: Option<JID>,
id: Option<String>,
@@ -70,7 +71,7 @@ impl IntoElement for Presence {
pub enum Other {}
-#[derive(Copy, Clone)]
+#[derive(Copy, Clone, Debug)]
pub enum PresenceType {
Error,
Probe,
@@ -112,7 +113,7 @@ impl ToString for PresenceType {
}
}
-#[derive(Copy, Clone)]
+#[derive(Copy, Clone, Debug)]
pub enum Show {
Away,
Chat,
@@ -160,7 +161,7 @@ impl ToString for Show {
}
}
-#[derive(Clone)]
+#[derive(Clone, Debug)]
pub struct Status {
lang: Option<String>,
status: String1024,
@@ -188,7 +189,7 @@ impl IntoElement for Status {
// TODO: enforce?
/// minLength 1 maxLength 1024
-#[derive(Clone)]
+#[derive(Clone, Debug)]
pub struct String1024(pub String);
impl FromStr for String1024 {
@@ -206,7 +207,7 @@ impl ToString for String1024 {
}
// xs:byte
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug)]
pub struct Priority(pub i8);
impl FromElement for Priority {