aboutsummaryrefslogtreecommitdiffstats
path: root/stanza/src
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2025-07-03 14:11:46 +0100
committerLibravatar cel 🌸 <cel@bunny.garden>2025-07-03 14:11:46 +0100
commit561dc2d6b6bc729ddd936ff7fe175c91b175e8b2 (patch)
treed3b7a2d8cd0ef0208d126c19ec79c760d2042b73 /stanza/src
parentec5652c3b207153251df279944e0fe36e0dd7dec (diff)
downloadluz-561dc2d6b6bc729ddd936ff7fe175c91b175e8b2.tar.gz
luz-561dc2d6b6bc729ddd936ff7fe175c91b175e8b2.tar.bz2
luz-561dc2d6b6bc729ddd936ff7fe175c91b175e8b2.zip
feat(stanza): xep-0334 message processing hintsHEADmain
Diffstat (limited to '')
-rw-r--r--stanza/src/client/message.rs42
-rw-r--r--stanza/src/lib.rs2
-rw-r--r--stanza/src/xep_0334.rs83
3 files changed, 127 insertions, 0 deletions
diff --git a/stanza/src/client/message.rs b/stanza/src/client/message.rs
index 66db921..3a7be9a 100644
--- a/stanza/src/client/message.rs
+++ b/stanza/src/client/message.rs
@@ -15,6 +15,8 @@ use crate::xep_0203::Delay;
use crate::xep_0280::{Private, Received, Sent};
#[cfg(feature = "xep_0297")]
use crate::xep_0297::Forwarded;
+#[cfg(feature = "xep_0334")]
+use crate::xep_0334::{NoCopy, NoPermanentStore, NoStore, Store};
use super::XMLNS;
@@ -46,6 +48,14 @@ pub struct Message {
pub received: Option<Received>,
#[cfg(feature = "xep_0280")]
pub private: Option<Private>,
+ #[cfg(feature = "xep_0334")]
+ pub no_permanent_store: Option<NoPermanentStore>,
+ #[cfg(feature = "xep_0334")]
+ pub no_store: Option<NoStore>,
+ #[cfg(feature = "xep_0334")]
+ pub no_copy: Option<NoCopy>,
+ #[cfg(feature = "xep_0334")]
+ pub store: Option<Store>,
}
impl FromElement for Message {
@@ -87,6 +97,18 @@ impl FromElement for Message {
#[cfg(feature = "xep_0280")]
let private = element.child_opt()?;
+ #[cfg(feature = "xep_0334")]
+ let no_permanent_store = element.child_opt()?;
+
+ #[cfg(feature = "xep_0334")]
+ let no_store = element.child_opt()?;
+
+ #[cfg(feature = "xep_0334")]
+ let no_copy = element.child_opt()?;
+
+ #[cfg(feature = "xep_0334")]
+ let store = element.child_opt()?;
+
Ok(Message {
from,
id,
@@ -112,6 +134,14 @@ impl FromElement for Message {
received,
#[cfg(feature = "xep_0280")]
private,
+ #[cfg(feature = "xep_0334")]
+ no_permanent_store,
+ #[cfg(feature = "xep_0334")]
+ no_store,
+ #[cfg(feature = "xep_0334")]
+ no_copy,
+ #[cfg(feature = "xep_0334")]
+ store,
})
}
}
@@ -158,6 +188,18 @@ impl IntoElement for Message {
#[cfg(feature = "xep_0280")]
let builder = builder.push_child_opt(self.private.clone());
+ #[cfg(feature = "xep_0334")]
+ let builder = builder.push_child_opt(self.no_permanent_store);
+
+ #[cfg(feature = "xep_0334")]
+ let builder = builder.push_child_opt(self.no_store);
+
+ #[cfg(feature = "xep_0334")]
+ let builder = builder.push_child_opt(self.no_copy);
+
+ #[cfg(feature = "xep_0334")]
+ let builder = builder.push_child_opt(self.store);
+
builder
}
}
diff --git a/stanza/src/lib.rs b/stanza/src/lib.rs
index 5b6ec11..4cb62a3 100644
--- a/stanza/src/lib.rs
+++ b/stanza/src/lib.rs
@@ -39,6 +39,8 @@ pub mod xep_0280;
pub mod xep_0297;
#[cfg(feature = "xep_0300")]
pub mod xep_0300;
+#[cfg(feature = "xep_0334")]
+pub mod xep_0334;
#[cfg(feature = "xep_0390")]
pub mod xep_0390;
diff --git a/stanza/src/xep_0334.rs b/stanza/src/xep_0334.rs
new file mode 100644
index 0000000..9667ad7
--- /dev/null
+++ b/stanza/src/xep_0334.rs
@@ -0,0 +1,83 @@
+use peanuts::{Element, FromElement, IntoElement};
+
+pub const XMLNS: &str = "urn:xmpp:hints";
+
+#[derive(Clone, Copy, Debug)]
+pub struct NoPermanentStore;
+
+impl FromElement for NoPermanentStore {
+ fn from_element(element: Element) -> peanuts::DeserializeResult<Self> {
+ element.check_name("no-permanent-store")?;
+ element.check_namespace(XMLNS)?;
+
+ element.no_more_content()?;
+
+ Ok(Self)
+ }
+}
+
+impl IntoElement for NoPermanentStore {
+ fn builder(&self) -> peanuts::ElementBuilder {
+ Element::builder("no-permanent-store", Some(XMLNS))
+ }
+}
+
+#[derive(Clone, Copy, Debug)]
+pub struct NoStore;
+
+impl FromElement for NoStore {
+ fn from_element(element: Element) -> peanuts::DeserializeResult<Self> {
+ element.check_name("no-store")?;
+ element.check_namespace(XMLNS)?;
+
+ element.no_more_content()?;
+
+ Ok(Self)
+ }
+}
+
+impl IntoElement for NoStore {
+ fn builder(&self) -> peanuts::ElementBuilder {
+ Element::builder("no-store", Some(XMLNS))
+ }
+}
+
+#[derive(Clone, Copy, Debug)]
+pub struct NoCopy;
+
+impl FromElement for NoCopy {
+ fn from_element(element: Element) -> peanuts::DeserializeResult<Self> {
+ element.check_name("no-copy")?;
+ element.check_namespace(XMLNS)?;
+
+ element.no_more_content()?;
+
+ Ok(Self)
+ }
+}
+
+impl IntoElement for NoCopy {
+ fn builder(&self) -> peanuts::ElementBuilder {
+ Element::builder("no-copy", Some(XMLNS))
+ }
+}
+
+#[derive(Clone, Copy, Debug)]
+pub struct Store;
+
+impl FromElement for Store {
+ fn from_element(element: Element) -> peanuts::DeserializeResult<Self> {
+ element.check_name("store")?;
+ element.check_namespace(XMLNS)?;
+
+ element.no_more_content()?;
+
+ Ok(Self)
+ }
+}
+
+impl IntoElement for Store {
+ fn builder(&self) -> peanuts::ElementBuilder {
+ Element::builder("store", Some(XMLNS))
+ }
+}