aboutsummaryrefslogtreecommitdiffstats
path: root/src/stanza/bind.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2024-12-04 18:18:37 +0000
committerLibravatar cel 🌸 <cel@bunny.garden>2024-12-04 18:18:37 +0000
commit1b91ff690488b65b552c90bd5392b9a300c8c981 (patch)
tree9c290f69b26eba0393d7bbc05ba29c28ea74a26e /src/stanza/bind.rs
parent03764f8cedb3f0a55a61be0f0a59faaa6357a83a (diff)
downloadluz-1b91ff690488b65b552c90bd5392b9a300c8c981.tar.gz
luz-1b91ff690488b65b552c90bd5392b9a300c8c981.tar.bz2
luz-1b91ff690488b65b552c90bd5392b9a300c8c981.zip
use cargo workspace
Diffstat (limited to 'src/stanza/bind.rs')
-rw-r--r--src/stanza/bind.rs99
1 files changed, 0 insertions, 99 deletions
diff --git a/src/stanza/bind.rs b/src/stanza/bind.rs
deleted file mode 100644
index 0e67a83..0000000
--- a/src/stanza/bind.rs
+++ /dev/null
@@ -1,99 +0,0 @@
-use peanuts::{
- element::{FromElement, IntoElement},
- Element,
-};
-
-use crate::JID;
-
-pub const XMLNS: &str = "urn:ietf:params:xml:ns:xmpp-bind";
-
-#[derive(Clone)]
-pub struct Bind {
- pub r#type: Option<BindType>,
-}
-
-impl FromElement for Bind {
- fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> {
- element.check_name("bind");
- element.check_name(XMLNS);
-
- let r#type = element.pop_child_opt()?;
-
- Ok(Bind { r#type })
- }
-}
-
-impl IntoElement for Bind {
- fn builder(&self) -> peanuts::element::ElementBuilder {
- Element::builder("bind", Some(XMLNS)).push_child_opt(self.r#type.clone())
- }
-}
-
-#[derive(Clone)]
-pub enum BindType {
- Resource(ResourceType),
- Jid(FullJidType),
-}
-
-impl FromElement for BindType {
- fn from_element(element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> {
- match element.identify() {
- (Some(XMLNS), "resource") => {
- Ok(BindType::Resource(ResourceType::from_element(element)?))
- }
- (Some(XMLNS), "jid") => Ok(BindType::Jid(FullJidType::from_element(element)?)),
- _ => Err(peanuts::DeserializeError::UnexpectedElement(element)),
- }
- }
-}
-
-impl IntoElement for BindType {
- fn builder(&self) -> peanuts::element::ElementBuilder {
- match self {
- BindType::Resource(resource_type) => resource_type.builder(),
- BindType::Jid(full_jid_type) => full_jid_type.builder(),
- }
- }
-}
-
-// minLength 8 maxLength 3071
-#[derive(Clone)]
-pub struct FullJidType(pub JID);
-
-impl FromElement for FullJidType {
- fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> {
- element.check_name("jid");
- element.check_namespace(XMLNS);
-
- let jid = element.pop_value()?;
-
- Ok(FullJidType(jid))
- }
-}
-
-impl IntoElement for FullJidType {
- fn builder(&self) -> peanuts::element::ElementBuilder {
- Element::builder("jid", Some(XMLNS)).push_text(self.0.clone())
- }
-}
-
-// minLength 1 maxLength 1023
-#[derive(Clone)]
-pub struct ResourceType(pub String);
-
-impl FromElement for ResourceType {
- fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> {
- element.check_name("resource")?;
- element.check_namespace(XMLNS)?;
-
- let resource = element.pop_value()?;
-
- Ok(ResourceType(resource))
- }
-}
-
-impl IntoElement for ResourceType {
- fn builder(&self) -> peanuts::element::ElementBuilder {
- Element::builder("resource", Some(XMLNS)).push_text(self.0.clone())
- }
-}