From c6bdf077b82b30f8228b56702bd3ee71d92b3910 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Sun, 1 Jun 2025 13:31:52 +0100 Subject: refactor: utilise new jid type safety --- stanza/src/stream.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'stanza/src/stream.rs') 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, - to: Option, + pub from: Option, + to: Option, id: Option, version: Option, // TODO: lang enum @@ -64,8 +64,8 @@ impl IntoElement for Stream { impl<'s> Stream { pub fn new( - from: Option, - to: Option, + from: Option, + to: Option, id: Option, version: Option, lang: Option, @@ -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, to: JID, id: Option, lang: String) -> Self { + pub fn new_client( + from: Option, + to: BareJID, + id: Option, + lang: String, + ) -> Self { Self { from, to: Some(to), -- cgit