diff options
author | 2025-06-01 13:31:52 +0100 | |
---|---|---|
committer | 2025-06-01 13:31:52 +0100 | |
commit | c6bdf077b82b30f8228b56702bd3ee71d92b3910 (patch) | |
tree | db12501d5d60906b77b19c1395a522967957c715 /stanza | |
parent | c196aecbe7b3b29fbfff9e997478688e6833b7f3 (diff) | |
download | luz-main.tar.gz luz-main.tar.bz2 luz-main.zip |
refactor: utilise new jid type safetyHEADmainjid-refactor
Diffstat (limited to 'stanza')
-rw-r--r-- | stanza/src/bind.rs | 4 | ||||
-rw-r--r-- | stanza/src/rfc_7395.rs | 10 | ||||
-rw-r--r-- | stanza/src/roster.rs | 4 | ||||
-rw-r--r-- | stanza/src/stream.rs | 17 | ||||
-rw-r--r-- | stanza/src/xep_0060/owner.rs | 4 |
5 files changed, 22 insertions, 17 deletions
diff --git a/stanza/src/bind.rs b/stanza/src/bind.rs index 3ce2246..0f0f681 100644 --- a/stanza/src/bind.rs +++ b/stanza/src/bind.rs @@ -1,4 +1,4 @@ -use jid::JID; +use jid::FullJID; use peanuts::{Element, FromElement, IntoElement}; pub const XMLNS: &str = "urn:ietf:params:xml:ns:xmpp-bind"; @@ -54,7 +54,7 @@ impl IntoElement for BindType { // minLength 8 maxLength 3071 #[derive(Clone, Debug)] -pub struct FullJidType(pub JID); +pub struct FullJidType(pub FullJID); impl FromElement for FullJidType { fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { diff --git a/stanza/src/rfc_7395.rs b/stanza/src/rfc_7395.rs index 64d9f70..73e947d 100644 --- a/stanza/src/rfc_7395.rs +++ b/stanza/src/rfc_7395.rs @@ -1,12 +1,12 @@ -use jid::JID; +use jid::BareJID; use peanuts::{Element, ElementBuilder, FromElement, IntoElement}; pub const XMLNS: &str = "urn:ietf:params:xml:ns:xmpp-framing"; #[derive(Debug)] pub struct Open { - pub from: Option<JID>, - pub to: Option<JID>, + pub from: Option<BareJID>, + pub to: Option<BareJID>, pub id: Option<String>, pub version: Option<String>, pub lang: Option<String>, @@ -46,8 +46,8 @@ impl IntoElement for Open { #[derive(Debug, Default)] pub struct Close { - pub from: Option<JID>, - pub to: Option<JID>, + pub from: Option<BareJID>, + pub to: Option<BareJID>, pub id: Option<String>, pub version: Option<String>, pub lang: Option<String>, diff --git a/stanza/src/roster.rs b/stanza/src/roster.rs index 14f65ef..dcbf017 100644 --- a/stanza/src/roster.rs +++ b/stanza/src/roster.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use jid::JID; +use jid::BareJID; use peanuts::{DeserializeError, Element, FromElement, IntoElement}; pub const XMLNS: &str = "jabber:iq:roster"; @@ -38,7 +38,7 @@ pub struct Item { /// signals subscription sub-states (server only) pub ask: bool, /// uniquely identifies item - pub jid: JID, + pub jid: BareJID, /// handle that is determined by user, not contact pub name: Option<String>, /// state of the presence subscription diff --git a/stanza/src/stream.rs b/stanza/src/stream.rs index 5be235a..e2f4f9b 100644 --- a/stanza/src/stream.rs +++ b/stanza/src/stream.rs @@ -1,6 +1,6 @@ use std::fmt::Display; -use jid::JID; +use jid::BareJID; use peanuts::{Element, ElementBuilder, FromElement, IntoElement}; use thiserror::Error; @@ -18,8 +18,8 @@ pub const XMLNS: &str = "http://etherx.jabber.org/streams"; // #[peanuts(xmlns = XMLNS)] #[derive(Debug)] pub struct Stream { - pub from: Option<JID>, - to: Option<JID>, + pub from: Option<BareJID>, + to: Option<BareJID>, id: Option<String>, version: Option<String>, // TODO: lang enum @@ -64,8 +64,8 @@ impl IntoElement for Stream { impl<'s> Stream { pub fn new( - from: Option<JID>, - to: Option<JID>, + from: Option<BareJID>, + to: Option<BareJID>, id: Option<String>, version: Option<String>, lang: Option<String>, @@ -81,7 +81,12 @@ impl<'s> Stream { /// For initial stream headers, the initiating entity SHOULD include the 'xml:lang' attribute. /// For privacy, it is better to not set `from` when sending a client stanza over an unencrypted connection. - pub fn new_client(from: Option<JID>, to: JID, id: Option<String>, lang: String) -> Self { + pub fn new_client( + from: Option<BareJID>, + to: BareJID, + id: Option<String>, + lang: String, + ) -> Self { Self { from, to: Some(to), diff --git a/stanza/src/xep_0060/owner.rs b/stanza/src/xep_0060/owner.rs index 0617712..4876bf5 100644 --- a/stanza/src/xep_0060/owner.rs +++ b/stanza/src/xep_0060/owner.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use jid::JID; +use jid::{BareJID, JID}; use peanuts::{DeserializeError, Element, FromElement, IntoElement}; use crate::xep_0004::X; @@ -85,7 +85,7 @@ impl IntoElement for Affiliations { #[derive(Clone, Debug)] pub struct Affiliation { affiliation: AffiliationType, - jid: JID, + jid: BareJID, } impl FromElement for Affiliation { |