From a46f34efb27fd017172c98c59d6ce2266d05995d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Wed, 18 Oct 2023 17:20:35 +0200 Subject: [PATCH] Update xmpp-rs deps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- Cargo.toml | 6 +++--- src/element.rs | 9 +++------ src/interpreter.rs | 10 ++++++---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cb561f8..4f85311 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,9 +8,9 @@ description = "Reimplementation of the Scansion project in Rust" [dependencies] nom = "7.1" -jid = { version = "0.9", features = [ "minidom" ] } -minidom = "0.15.1" -xmpp-parsers = "0.19.2" +jid = { version = "*", features = [ "minidom" ] } +minidom = "*" +xmpp-parsers = "0.20" nom_locate = "4.0.0" rand = "0.8" diff --git a/src/element.rs b/src/element.rs index 661a7e7..4124479 100644 --- a/src/element.rs +++ b/src/element.rs @@ -43,7 +43,6 @@ use std::str::FromStr; use crate::parsers::parse_variable; use crate::types::{Client, Context, Entity, VariableAttr}; -use jid::BareJid; use minidom::{Element, Error as MinidomError, Node}; use xmpp_parsers::{iq::Iq, message::Message, presence::Presence, Error as XMPPParserError}; @@ -182,7 +181,7 @@ impl PartialEq> for ScanNodes { let scan = ScanNode::new(node); res && filtered_other .iter() - .find(|onode| &&scan == onode) + .find(|onode| &scan == *onode) .is_some() }) } @@ -282,13 +281,11 @@ fn apply_context(mut elem: Element, context: &Context) -> Element { if let Ok((_, var)) = parse_variable(val.as_str().into()) { match var { VariableAttr::FullJid(name) => match context.get(&name) { - Some(Entity::Client(Client { jid, .. })) => *val = String::from(jid.clone()), + Some(Entity::Client(Client { jid, .. })) => *val = format!("{jid}"), _ => (), }, VariableAttr::BareJid(name) => match context.get(&name) { - Some(Entity::Client(Client { jid, .. })) => { - *val = String::from(BareJid::from(jid.clone())) - } + Some(Entity::Client(Client { jid, .. })) => *val = format!("{}", jid.to_bare()), _ => (), }, } diff --git a/src/interpreter.rs b/src/interpreter.rs index 81af096..8cfc38a 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -61,7 +61,9 @@ fn bind_context(context: Context) -> Context { match context { Entity::Client(ref mut client) => match &client.jid { Jid::Bare(bare) => { - let jid = bare.clone().with_resource(make_resource()); + let res = make_resource(); + // u8 should always be a valid resource? + let jid = bare.clone().with_resource_str(&res).unwrap(); client.jid = Jid::Full(jid) } _ => (), @@ -145,7 +147,7 @@ pub fn read_actions_component(spec: Spec, context: &Context) -> Result BareJid::from(full.clone()), + }) => full.to_bare(), Entity::Client(Client { jid: Jid::Bare(bare), .. @@ -243,8 +245,8 @@ louise receives: password, .. })) => { - assert_eq!(full.node, Some(String::from("louise"))); - assert_eq!(full.domain, String::from("localhost")); + assert_eq!(full.node_str(), Some(String::from("louise")).as_deref()); + assert_eq!(full.domain_str(), String::from("localhost")); assert_eq!(password, "password"); } other => panic!("Error: context: {other:?}"),