From 1e3f940db9f812591d7b34f9e68989b9079ec6ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Mon, 10 Jun 2019 23:17:09 +0200 Subject: [PATCH] Update jid dependency to 0.6.0: Jid split change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- Cargo.toml | 2 +- src/bind.rs | 6 +++--- src/blocking.rs | 11 +++++------ src/bookmarks.rs | 6 +++--- src/lib.rs | 6 +++--- src/muc/user.rs | 10 +++++----- src/roster.rs | 14 +++++++------- src/stream.rs | 12 ++++++------ src/websocket.rs | 10 +++++----- 9 files changed, 38 insertions(+), 39 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 69b94a5..b1e84c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" [dependencies] minidom = "0.10.0" -jid = { version = "0.5.3", features = ["minidom"] } +jid = { version = "0.6.0", features = ["minidom"] } base64 = "0.10" digest = "0.8" sha-1 = "0.8" diff --git a/src/bind.rs b/src/bind.rs index 1d50963..408c08b 100644 --- a/src/bind.rs +++ b/src/bind.rs @@ -7,7 +7,7 @@ use crate::util::error::Error; use crate::iq::{IqResultPayload, IqSetPayload}; use crate::ns; -use jid::Jid; +use jid::FullJid; use minidom::Element; use std::str::FromStr; use std::convert::TryFrom; @@ -26,7 +26,7 @@ pub enum Bind { Resource(String), /// The full JID returned by the server for this client. - Jid(Jid), + Jid(FullJid), } impl Bind { @@ -61,7 +61,7 @@ impl TryFrom for Bind { } else if child.is("jid", ns::BIND) { check_no_attributes!(child, "jid"); check_no_children!(child, "jid"); - bind = Bind::Jid(Jid::from_str(&child.text())?); + bind = Bind::Jid(FullJid::from_str(&child.text())?); } else { return Err(Error::ParseError("Unknown element in bind.")); } diff --git a/src/blocking.rs b/src/blocking.rs index b44c411..f218b21 100644 --- a/src/blocking.rs +++ b/src/blocking.rs @@ -101,6 +101,7 @@ generate_empty_element!( #[cfg(test)] mod tests { use super::*; + use jid::BareJid; #[cfg(target_pointer_width = "32")] #[test] @@ -143,16 +144,14 @@ mod tests { fn test_items() { let elem: Element = "".parse().unwrap(); let two_items = vec![ - Jid { + Jid::Bare(BareJid { node: Some(String::from("coucou")), domain: String::from("coucou"), - resource: None, - }, - Jid { + }), + Jid::Bare(BareJid { node: None, domain: String::from("domain"), - resource: None, - }, + }), ]; let result_elem = elem.clone(); diff --git a/src/bookmarks.rs b/src/bookmarks.rs index d8b5a9c..1424686 100644 --- a/src/bookmarks.rs +++ b/src/bookmarks.rs @@ -4,7 +4,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use jid::Jid; +use jid::BareJid; generate_attribute!( /// Whether a conference bookmark should be joined automatically. @@ -21,7 +21,7 @@ generate_element!( autojoin: Default = "autojoin", /// The JID of the conference. - jid: Required = "jid", + jid: Required = "jid", /// A user-defined name for this conference. name: Required = "name", @@ -113,7 +113,7 @@ mod tests { assert_eq!(storage.conferences[0].autojoin, Autojoin::True); assert_eq!( storage.conferences[0].jid, - Jid::bare("test-muc", "muc.localhost") + BareJid::new("test-muc", "muc.localhost") ); assert_eq!(storage.conferences[0].name, "Test MUC"); assert_eq!(storage.conferences[0].clone().nick.unwrap(), "Coucou"); diff --git a/src/lib.rs b/src/lib.rs index ebeddf2..6863afe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,8 +15,8 @@ //! [`TryFrom`]: ../try_from/trait.TryFrom.html //! [`Element`]: ../minidom/element/struct.Element.html -// Copyright (c) 2017-2018 Emmanuel Gil Peyrot -// Copyright (c) 2017 Maxime “pep” Buquet +// Copyright (c) 2017-2019 Emmanuel Gil Peyrot +// Copyright (c) 2017-2019 Maxime “pep” Buquet // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -25,7 +25,7 @@ #![deny(missing_docs)] pub use minidom::Element; -pub use jid::{Jid, JidParseError}; +pub use jid::{Jid, BareJid, FullJid, JidParseError}; pub use std::convert::{TryFrom, TryInto}; pub use crate::util::error::Error; diff --git a/src/muc/user.rs b/src/muc/user.rs index bc8012d..3621450 100644 --- a/src/muc/user.rs +++ b/src/muc/user.rs @@ -7,7 +7,7 @@ use crate::util::error::Error; use crate::ns; -use jid::Jid; +use jid::FullJid; use minidom::Element; use std::convert::TryFrom; @@ -82,7 +82,7 @@ Status, "status", MUC_USER, "code", { #[derive(Debug, Clone, PartialEq)] pub enum Actor { /// The full JID associated with this user. - Jid(Jid), + Jid(FullJid), /// The nickname of this user. Nick(String), @@ -95,7 +95,7 @@ impl TryFrom for Actor { check_self!(elem, "actor", MUC_USER); check_no_unknown_attributes!(elem, "actor", ["jid", "nick"]); check_no_children!(elem, "actor"); - let jid: Option = get_attr!(elem, "jid", Option); + let jid: Option = get_attr!(elem, "jid", Option); let nick = get_attr!(elem, "nick", Option); match (jid, nick) { @@ -190,7 +190,7 @@ generate_element!( affiliation: Required = "affiliation", /// The real JID of this user, if you are allowed to see it. - jid: Option = "jid", + jid: Option = "jid", /// The current nickname of this user. nick: Option = "nick", @@ -448,7 +448,7 @@ mod tests { Actor::Jid(jid) => jid, _ => panic!(), }; - assert_eq!(jid, "foo@bar/baz".parse::().unwrap()); + assert_eq!(jid, "foo@bar/baz".parse::().unwrap()); } #[test] diff --git a/src/roster.rs b/src/roster.rs index 65c1fdf..dc615c7 100644 --- a/src/roster.rs +++ b/src/roster.rs @@ -5,7 +5,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. use crate::iq::{IqGetPayload, IqResultPayload, IqSetPayload}; -use jid::Jid; +use jid::BareJid; generate_elem_id!( /// Represents a group a contact is part of. @@ -50,7 +50,7 @@ generate_element!( Item, "item", ROSTER, attributes: [ /// JID of this contact. - jid: Required = "jid", + jid: Required = "jid", /// Name of this contact. name: OptionEmpty = "name", @@ -172,7 +172,7 @@ mod tests { assert_eq!(roster.items.len(), 4); assert_eq!( roster.items[0].jid, - Jid::from_str("romeo@example.net").unwrap() + BareJid::from_str("romeo@example.net").unwrap() ); assert_eq!(roster.items[0].name, Some(String::from("Romeo"))); assert_eq!(roster.items[0].subscription, Subscription::Both); @@ -184,7 +184,7 @@ mod tests { assert_eq!( roster.items[3].jid, - Jid::from_str("contact@example.org").unwrap() + BareJid::from_str("contact@example.org").unwrap() ); assert_eq!(roster.items[3].name, Some(String::from("MyContact"))); assert_eq!(roster.items[3].subscription, Subscription::None); @@ -213,7 +213,7 @@ mod tests { assert_eq!(roster.items.len(), 1); assert_eq!( roster.items[0].jid, - Jid::from_str("test@example.org").unwrap() + BareJid::from_str("test@example.org").unwrap() ); assert_eq!(roster.items[0].name, None); assert_eq!(roster.items[0].groups.len(), 2); @@ -248,7 +248,7 @@ mod tests { assert_eq!(roster.items.len(), 1); assert_eq!( roster.items[0].jid, - Jid::from_str("nurse@example.com").unwrap() + BareJid::from_str("nurse@example.com").unwrap() ); assert_eq!(roster.items[0].name, Some(String::from("Nurse"))); assert_eq!(roster.items[0].groups.len(), 1); @@ -270,7 +270,7 @@ mod tests { assert_eq!(roster.items.len(), 1); assert_eq!( roster.items[0].jid, - Jid::from_str("nurse@example.com").unwrap() + BareJid::from_str("nurse@example.com").unwrap() ); assert!(roster.items[0].name.is_none()); assert!(roster.items[0].groups.is_empty()); diff --git a/src/stream.rs b/src/stream.rs index 1d4715f..021b642 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -4,17 +4,17 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use jid::Jid; +use jid::BareJid; generate_element!( /// The stream opening for client-server communications. Stream, "stream", STREAM, attributes: [ /// The JID of the entity opening this stream. - from: Option = "from", + from: Option = "from", /// The JID of the entity receiving this stream opening. - to: Option = "to", + to: Option = "to", /// The id of the stream, used for authentication challenges. id: Option = "id", @@ -30,7 +30,7 @@ generate_element!( impl Stream { /// Creates a simple client→server `` element. - pub fn new(to: Jid) -> Stream { + pub fn new(to: BareJid) -> Stream { Stream { from: None, to: Some(to), @@ -42,7 +42,7 @@ impl Stream { /// Sets the [@from](#structfield.from) attribute on this `` /// element. - pub fn with_from(mut self, from: Jid) -> Stream { + pub fn with_from(mut self, from: BareJid) -> Stream { self.from = Some(from); self } @@ -92,7 +92,7 @@ mod tests { fn test_simple() { let elem: Element = "".parse().unwrap(); let stream = Stream::try_from(elem).unwrap(); - assert_eq!(stream.from, Some(Jid::domain("some-server.example"))); + assert_eq!(stream.from, Some(BareJid::domain("some-server.example"))); assert_eq!(stream.to, None); assert_eq!(stream.id, Some(String::from("abc"))); assert_eq!(stream.version, Some(String::from("1.0"))); diff --git a/src/websocket.rs b/src/websocket.rs index b8c02e2..dc2670f 100644 --- a/src/websocket.rs +++ b/src/websocket.rs @@ -4,17 +4,17 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use jid::Jid; +use jid::BareJid; generate_element!( /// The stream opening for WebSocket. Open, "open", WEBSOCKET, attributes: [ /// The JID of the entity opening this stream. - from: Option = "from", + from: Option = "from", /// The JID of the entity receiving this stream opening. - to: Option = "to", + to: Option = "to", /// The id of the stream, used for authentication challenges. id: Option = "id", @@ -30,7 +30,7 @@ generate_element!( impl Open { /// Creates a simple client→server `` element. - pub fn new(to: Jid) -> Open { + pub fn new(to: BareJid) -> Open { Open { from: None, to: Some(to), @@ -42,7 +42,7 @@ impl Open { /// Sets the [@from](#structfield.from) attribute on this `` /// element. - pub fn with_from(mut self, from: Jid) -> Open { + pub fn with_from(mut self, from: BareJid) -> Open { self.from = Some(from); self }