aboutsummaryrefslogtreecommitdiffstats
path: root/stanza/src/xep_0203.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2025-03-24 12:22:08 +0000
committerLibravatar cel 🌸 <cel@bunny.garden>2025-03-24 12:31:01 +0000
commit54ca5eb3155d1cfcadced7c0a3a405ce1d51ecf6 (patch)
tree49a59ebae7bd7b58caaa748a20b745397c37c2e3 /stanza/src/xep_0203.rs
parent9f0a480bc4c6ee3ac8c707b05d40529afef0d78f (diff)
downloadluz-54ca5eb3155d1cfcadced7c0a3a405ce1d51ecf6.tar.gz
luz-54ca5eb3155d1cfcadced7c0a3a405ce1d51ecf6.tar.bz2
luz-54ca5eb3155d1cfcadced7c0a3a405ce1d51ecf6.zip
feat(stanza): xep-0203
Diffstat (limited to '')
-rw-r--r--stanza/src/xep_0203.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/stanza/src/xep_0203.rs b/stanza/src/xep_0203.rs
new file mode 100644
index 0000000..b8f9239
--- /dev/null
+++ b/stanza/src/xep_0203.rs
@@ -0,0 +1,34 @@
+use chrono::{DateTime, Utc};
+use jid::JID;
+use peanuts::{
+ element::{FromElement, IntoElement},
+ Element,
+};
+
+pub const XMLNS: &str = "urn:xmpp:delay";
+
+#[derive(Debug, Clone)]
+pub struct Delay {
+ pub from: Option<JID>,
+ pub stamp: DateTime<Utc>,
+}
+
+impl FromElement for Delay {
+ fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> {
+ element.check_name("delay")?;
+ element.check_namespace(XMLNS)?;
+
+ let from = element.attribute_opt("from")?;
+ let stamp = element.attribute("stamp")?;
+
+ Ok(Delay { from, stamp })
+ }
+}
+
+impl IntoElement for Delay {
+ fn builder(&self) -> peanuts::element::ElementBuilder {
+ Element::builder("delay", Some(XMLNS))
+ .push_attribute_opt("from", self.from.clone())
+ .push_attribute("stamp", self.stamp.format("%C%y-%m-%dT%H:%M:%S%.3f%:z"))
+ }
+}