From 1f43cd934b56bda603deb49efa22f6f07f0ed8b1 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 20 Jul 2017 20:03:15 +0100 Subject: [PATCH] Use TryFrom from the try_from crate, instead of the unstable feature. This makes xmpp-parsers usable on stable. --- Cargo.toml | 1 + src/attention.rs | 6 +++--- src/caps.rs | 4 ++-- src/chatstates.rs | 4 ++-- src/data_forms.rs | 4 ++-- src/delay.rs | 4 ++-- src/disco.rs | 6 +++--- src/ecaps2.rs | 4 ++-- src/eme.rs | 4 ++-- src/forwarding.rs | 4 ++-- src/hashes.rs | 4 ++-- src/ibb.rs | 4 ++-- src/ibr.rs | 4 ++-- src/idle.rs | 4 ++-- src/iq.rs | 10 +++++----- src/jingle.rs | 8 ++++---- src/jingle_ft.rs | 4 ++-- src/jingle_ibb.rs | 4 ++-- src/jingle_message.rs | 4 ++-- src/jingle_s5b.rs | 4 ++-- src/lib.rs | 3 +-- src/mam.rs | 10 +++++----- src/media_element.rs | 4 ++-- src/message.rs | 6 +++--- src/message_correct.rs | 4 ++-- src/muc/muc.rs | 4 ++-- src/muc/user.rs | 15 +++++++-------- src/ping.rs | 4 ++-- src/presence.rs | 6 +++--- src/pubsub/event.rs | 4 ++-- src/receipts.rs | 4 ++-- src/roster.rs | 6 +++--- src/rsm.rs | 4 ++-- src/stanza_error.rs | 4 ++-- src/stanza_id.rs | 4 ++-- 35 files changed, 86 insertions(+), 87 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 608f2ff536685715ccc4a39e5d221499772a85ce..b70538110dc033d592a6b06bab35c010d605c298 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,3 +22,4 @@ sha2 = "0.6.0" sha3 = "0.6.0" blake2 = "0.6.0" chrono = "0.4.0" +try_from = "0.2.2" diff --git a/src/attention.rs b/src/attention.rs index b28b5cc300967f03c455814f1008cd06c93c264b..c53040c4876bc0046e7f0b5974b13f5a5d87b9eb 100644 --- a/src/attention.rs +++ b/src/attention.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 std::convert::TryFrom; +use try_from::TryFrom; use minidom::Element; @@ -16,7 +16,7 @@ use ns; pub struct Attention; impl TryFrom for Attention { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("attention", ns::ATTENTION) { @@ -39,7 +39,7 @@ impl Into for Attention { #[cfg(test)] mod tests { - use std::convert::TryFrom; + use try_from::TryFrom; use minidom::Element; use error::Error; use super::Attention; diff --git a/src/caps.rs b/src/caps.rs index e883a64a7863f73979b902e9207e3622890146f2..aad50eb2d644807a73f50922ce8fe7058f0f7ec5 100644 --- a/src/caps.rs +++ b/src/caps.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 std::convert::TryFrom; +use try_from::TryFrom; use disco::{Feature, Identity, DiscoInfoResult, DiscoInfoQuery}; use data_forms::DataForm; @@ -29,7 +29,7 @@ pub struct Caps { } impl TryFrom for Caps { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("c", ns::CAPS) { diff --git a/src/chatstates.rs b/src/chatstates.rs index 47df01e0cd63330b65a1517c0c40fa3e40f97b33..ff1baa9563bf82dad351fcfe15aeb5002b0e9b5e 100644 --- a/src/chatstates.rs +++ b/src/chatstates.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 std::convert::TryFrom; +use try_from::TryFrom; use minidom::Element; @@ -22,7 +22,7 @@ pub enum ChatState { } impl TryFrom for ChatState { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if elem.ns() != Some(ns::CHATSTATES) { diff --git a/src/data_forms.rs b/src/data_forms.rs index 7e187ec194b60a1269e1fa78d5d72c467386d1cb..d4678c097573e6795345449330c3f67b248a87d5 100644 --- a/src/data_forms.rs +++ b/src/data_forms.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 std::convert::TryFrom; +use try_from::TryFrom; use std::str::FromStr; use minidom::{Element, IntoElements, IntoAttributeValue, ElementEmitter}; @@ -103,7 +103,7 @@ pub struct DataForm { } impl TryFrom for DataForm { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("x", ns::DATA_FORMS) { diff --git a/src/delay.rs b/src/delay.rs index d744751da9ec01e743ae9358d0a3bf1319a6666b..7b56ab7eeeff733bb0f587ea4b2e280464b804bc 100644 --- a/src/delay.rs +++ b/src/delay.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 std::convert::TryFrom; +use try_from::TryFrom; use minidom::Element; use chrono::{DateTime, FixedOffset}; @@ -22,7 +22,7 @@ pub struct Delay { } impl TryFrom for Delay { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("delay", ns::DELAY) { diff --git a/src/disco.rs b/src/disco.rs index a36f997e6c89e2d7bd475bf404f94ef16e53b6b0..43727d51d82ba3ebf1d4ce1a6a04e200bee7dfb5 100644 --- a/src/disco.rs +++ b/src/disco.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 std::convert::TryFrom; +use try_from::TryFrom; use minidom::{Element, IntoElements, ElementEmitter}; @@ -19,7 +19,7 @@ pub struct DiscoInfoQuery { } impl TryFrom for DiscoInfoQuery { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("query", ns::DISCO_INFO) { @@ -103,7 +103,7 @@ pub struct DiscoInfoResult { } impl TryFrom for DiscoInfoResult { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("query", ns::DISCO_INFO) { diff --git a/src/ecaps2.rs b/src/ecaps2.rs index da74533d8e366f8135d9f2f7699201423fb7b059..0e92796de154b539ffd0323840d60fcba3599916 100644 --- a/src/ecaps2.rs +++ b/src/ecaps2.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 std::convert::TryFrom; +use try_from::TryFrom; use disco::{Feature, Identity, DiscoInfoResult, DiscoInfoQuery}; use data_forms::DataForm; @@ -26,7 +26,7 @@ pub struct ECaps2 { } impl TryFrom for ECaps2 { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("c", ns::ECAPS2) { diff --git a/src/eme.rs b/src/eme.rs index fe9738613ecafe0d5b7e7e13b7a280643bf3955e..ee71e21c75cd96c3a888654a6602c3955a9eb769 100644 --- a/src/eme.rs +++ b/src/eme.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 std::convert::TryFrom; +use try_from::TryFrom; use minidom::Element; @@ -19,7 +19,7 @@ pub struct ExplicitMessageEncryption { } impl TryFrom for ExplicitMessageEncryption { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("encryption", ns::EME) { diff --git a/src/forwarding.rs b/src/forwarding.rs index 9ad416b8fcf5ea23775bcac763b37235763c46c6..d10860ff30a9cee175461c38b6b26eca99ff7077 100644 --- a/src/forwarding.rs +++ b/src/forwarding.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 std::convert::TryFrom; +use try_from::TryFrom; use minidom::Element; @@ -23,7 +23,7 @@ pub struct Forwarded { } impl TryFrom for Forwarded { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("forwarded", ns::FORWARD) { diff --git a/src/hashes.rs b/src/hashes.rs index 07f2822c479fbe9feb8e06ec93308caaad00920f..6520fede0a90e880aa2ccee3df8276b24ed615aa 100644 --- a/src/hashes.rs +++ b/src/hashes.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 std::convert::TryFrom; +use try_from::TryFrom; use std::str::FromStr; use minidom::{Element, IntoAttributeValue}; @@ -75,7 +75,7 @@ pub struct Hash { } impl TryFrom for Hash { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("hash", ns::HASHES) { diff --git a/src/ibb.rs b/src/ibb.rs index ad9873778afcfc4cb362fecb38fdd59ab0e9991d..969f34194fd25fe8836689b6b90d4aee4577976b 100644 --- a/src/ibb.rs +++ b/src/ibb.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 std::convert::TryFrom; +use try_from::TryFrom; use std::str::FromStr; use minidom::{Element, IntoAttributeValue}; @@ -37,7 +37,7 @@ pub enum IBB { } impl TryFrom for IBB { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if elem.is("open", ns::IBB) { diff --git a/src/ibr.rs b/src/ibr.rs index 183d371638f203b948f522411a690a85192005e1..a0c7cc723b7f0e1947a618a054e8f012b1f532fc 100644 --- a/src/ibr.rs +++ b/src/ibr.rs @@ -5,7 +5,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. use std::collections::HashMap; -use std::convert::TryFrom; +use try_from::TryFrom; use minidom::{Element, IntoElements, ElementEmitter}; @@ -26,7 +26,7 @@ pub struct Query { } impl TryFrom for Query { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("query", ns::REGISTER) { diff --git a/src/idle.rs b/src/idle.rs index 82009668bfbeed21044f8a7ef0b61f47222d2fd3..3809ff8b0e05b208291d504bf2d761caa5cd5067 100644 --- a/src/idle.rs +++ b/src/idle.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 std::convert::TryFrom; +use try_from::TryFrom; use minidom::Element; use chrono::{DateTime, FixedOffset}; @@ -19,7 +19,7 @@ pub struct Idle { } impl TryFrom for Idle { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("idle", ns::IDLE) { diff --git a/src/iq.rs b/src/iq.rs index 976d79f8f7656b1ba1a61b7fa5c509b5b1057308..1016102194fd1bf6846be50b96d8c78afb61e546 100644 --- a/src/iq.rs +++ b/src/iq.rs @@ -5,7 +5,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 std::convert::TryFrom; +use try_from::TryFrom; use minidom::Element; use minidom::IntoAttributeValue; @@ -61,7 +61,7 @@ pub enum IqResultPayload { } impl TryFrom for IqGetPayload { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { Ok(match (elem.name().as_ref(), elem.ns().unwrap().as_ref()) { @@ -98,7 +98,7 @@ impl Into for IqGetPayload { } impl TryFrom for IqSetPayload { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { Ok(match (elem.name().as_ref(), elem.ns().unwrap().as_ref()) { @@ -137,7 +137,7 @@ impl Into for IqSetPayload { } impl TryFrom for IqResultPayload { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { Ok(match (elem.name().as_ref(), elem.ns().unwrap().as_ref()) { @@ -199,7 +199,7 @@ pub struct Iq { } impl TryFrom for Iq { - type Error = Error; + type Err = Error; fn try_from(root: Element) -> Result { if !root.is("iq", ns::JABBER_CLIENT) { diff --git a/src/jingle.rs b/src/jingle.rs index ece7fa023a89c934ad4400dd93047c8368e731f8..c9470326f32803c1f85c4714dd8be12f85c6993a 100644 --- a/src/jingle.rs +++ b/src/jingle.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 std::convert::TryFrom; +use try_from::TryFrom; use std::str::FromStr; use minidom::{Element, IntoElements, IntoAttributeValue, ElementEmitter}; @@ -57,7 +57,7 @@ pub struct Content { } impl TryFrom for Content { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("content", ns::JINGLE) { @@ -196,7 +196,7 @@ pub struct ReasonElement { } impl TryFrom for ReasonElement { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("reason", ns::JINGLE) { @@ -261,7 +261,7 @@ pub struct Jingle { } impl TryFrom for Jingle { - type Error = Error; + type Err = Error; fn try_from(root: Element) -> Result { if !root.is("jingle", ns::JINGLE) { diff --git a/src/jingle_ft.rs b/src/jingle_ft.rs index a70b012b200b15dbec53db1bc0e44c2ca2d650a7..5e070cd5e6d8f4291ebf87da8c1e31749049914c 100644 --- a/src/jingle_ft.rs +++ b/src/jingle_ft.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 std::convert::TryFrom; +use try_from::TryFrom; use hashes::Hash; @@ -85,7 +85,7 @@ impl IntoElements for Received { } impl TryFrom for Description { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("description", ns::JINGLE_FT) { diff --git a/src/jingle_ibb.rs b/src/jingle_ibb.rs index 72ebba550ea5ae6e9ac6d02faadd8a7d210624fa..08a313297e88c1b16a5b3d9a83229679c54f0b3a 100644 --- a/src/jingle_ibb.rs +++ b/src/jingle_ibb.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 std::convert::TryFrom; +use try_from::TryFrom; use std::str::FromStr; use minidom::{Element, IntoAttributeValue}; @@ -25,7 +25,7 @@ pub struct Transport { } impl TryFrom for Transport { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("transport", ns::JINGLE_IBB) { diff --git a/src/jingle_message.rs b/src/jingle_message.rs index d61133427655ebeb9037c259279bdc37dd91341b..216e1877386fa185894a9bb0936c111b833693b9 100644 --- a/src/jingle_message.rs +++ b/src/jingle_message.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 std::convert::TryFrom; +use try_from::TryFrom; use minidom::Element; @@ -44,7 +44,7 @@ fn check_empty_and_get_sid(elem: Element) -> Result { } impl TryFrom for JingleMI { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if elem.ns() != Some(ns::JINGLE_MESSAGE) { diff --git a/src/jingle_s5b.rs b/src/jingle_s5b.rs index 57807be313ec817c1fbd9d7c8f44791c568d2e7f..603dbb242f7246e7ed4e388e3d895f90bb31020d 100644 --- a/src/jingle_s5b.rs +++ b/src/jingle_s5b.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 std::convert::TryFrom; +use try_from::TryFrom; use std::str::FromStr; use minidom::{Element, IntoAttributeValue}; @@ -73,7 +73,7 @@ pub struct Transport { } impl TryFrom for Transport { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if elem.is("transport", ns::JINGLE_S5B) { diff --git a/src/lib.rs b/src/lib.rs index f82e6df349d6d63df7f87a9fb64fb7e2261f8e51..35dacabd7cf1c705514a6ce56cf46383b2d6ba58 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,8 +13,6 @@ // 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/. -#![feature(try_from)] - extern crate minidom; extern crate jid; extern crate base64; @@ -24,6 +22,7 @@ extern crate sha2; extern crate sha3; extern crate blake2; extern crate chrono; +extern crate try_from; macro_rules! get_attr { ($elem:ident, $attr:tt, $type:tt) => ( diff --git a/src/mam.rs b/src/mam.rs index 920cf8d01a76ae44d95839ad658405e99372dcd6..62b035e1691487c1932bdf1dd54de955c3b92db6 100644 --- a/src/mam.rs +++ b/src/mam.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 std::convert::TryFrom; +use try_from::TryFrom; use std::str::FromStr; use minidom::{Element, IntoAttributeValue}; @@ -53,7 +53,7 @@ pub struct Prefs { } impl TryFrom for Query { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("query", ns::MAM) { @@ -77,7 +77,7 @@ impl TryFrom for Query { } impl TryFrom for Result_ { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("result", ns::MAM) { @@ -103,7 +103,7 @@ impl TryFrom for Result_ { } impl TryFrom for Fin { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("fin", ns::MAM) { @@ -129,7 +129,7 @@ impl TryFrom for Fin { } impl TryFrom for Prefs { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("prefs", ns::MAM) { diff --git a/src/media_element.rs b/src/media_element.rs index b1c36a64638fe7ee28a8de7ab376e4007a1f3e55..aa15efb5637e8d440f40a7de5f1d58d6fedd5fd1 100644 --- a/src/media_element.rs +++ b/src/media_element.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 std::convert::TryFrom; +use try_from::TryFrom; use minidom::{Element, IntoElements, ElementEmitter}; @@ -42,7 +42,7 @@ pub struct MediaElement { } impl TryFrom for MediaElement { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("media", ns::MEDIA_ELEMENT) { diff --git a/src/message.rs b/src/message.rs index 47c8db16eaebfbbb8256a7a45a2ce91a589bb4d0..3c7fefc8e4065e11e29d149157d8b833ca4ea2dd 100644 --- a/src/message.rs +++ b/src/message.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 std::convert::TryFrom; +use try_from::TryFrom; use std::str::FromStr; use std::collections::BTreeMap; @@ -43,7 +43,7 @@ pub enum MessagePayload { } impl TryFrom for MessagePayload { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { Ok(match (elem.name().as_ref(), elem.ns().unwrap().as_ref()) { @@ -143,7 +143,7 @@ impl Message { } impl TryFrom for Message { - type Error = Error; + type Err = Error; fn try_from(root: Element) -> Result { if !root.is("message", ns::JABBER_CLIENT) { diff --git a/src/message_correct.rs b/src/message_correct.rs index 8ce747f114d9139b843c58bf34d52d8a46ec5043..5376f8604370de2e889bd3a642cb521a1e81d9f7 100644 --- a/src/message_correct.rs +++ b/src/message_correct.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 std::convert::TryFrom; +use try_from::TryFrom; use minidom::Element; @@ -18,7 +18,7 @@ pub struct Replace { } impl TryFrom for Replace { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("replace", ns::MESSAGE_CORRECT) { diff --git a/src/muc/muc.rs b/src/muc/muc.rs index 75667d877352ccd6e38404a1a16ef4e1431cf7db..e7e6a238e0b64329df12150a4ab1de9cb990b7e7 100644 --- a/src/muc/muc.rs +++ b/src/muc/muc.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 std::convert::TryFrom; +use try_from::TryFrom; use minidom::Element; @@ -18,7 +18,7 @@ pub struct Muc { } impl TryFrom for Muc { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("x", ns::MUC) { diff --git a/src/muc/user.rs b/src/muc/user.rs index 833b5604a959b43f9455f0003331b001f1646574..1609b0c8d1680df7d7a4f66e18d282116e43e61a 100644 --- a/src/muc/user.rs +++ b/src/muc/user.rs @@ -4,8 +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 std::convert::TryFrom; -use std::convert::TryInto; +use try_from::{TryFrom, TryInto}; use std::str::FromStr; use minidom::{Element, IntoElements, IntoAttributeValue, ElementEmitter}; @@ -74,7 +73,7 @@ pub enum Status { } impl TryFrom for Status { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("status", ns::MUC_USER) { @@ -160,7 +159,7 @@ pub enum Actor { } impl TryFrom for Actor { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("actor", ns::MUC_USER) { @@ -210,7 +209,7 @@ pub struct Continue { } impl TryFrom for Continue { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("continue", ns::MUC_USER) { @@ -247,7 +246,7 @@ impl IntoElements for Continue { pub struct Reason(String); impl TryFrom for Reason { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("reason", ns::MUC_USER) { @@ -305,7 +304,7 @@ pub struct Item { } impl TryFrom for Item { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("item", ns::MUC_USER) { @@ -374,7 +373,7 @@ pub struct MucUser { } impl TryFrom for MucUser { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("x", ns::MUC_USER) { diff --git a/src/ping.rs b/src/ping.rs index 84a7cebf0d9796abc09046bb29346a617c84b99c..272044517ae4b2873212364011b8946f284e3e26 100644 --- a/src/ping.rs +++ b/src/ping.rs @@ -5,7 +5,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 std::convert::TryFrom; +use try_from::TryFrom; use minidom::Element; @@ -17,7 +17,7 @@ use ns; pub struct Ping; impl TryFrom for Ping { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("ping", ns::PING) { diff --git a/src/presence.rs b/src/presence.rs index 74458797a457e320a0e158790cca120f5f8b90c4..1eb0b23fb86f56faec9065f417d0ddaa78c4dc95 100644 --- a/src/presence.rs +++ b/src/presence.rs @@ -5,7 +5,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 std::convert::TryFrom; +use try_from::TryFrom; use std::str::FromStr; use std::collections::BTreeMap; @@ -91,7 +91,7 @@ pub enum PresencePayload { } impl TryFrom for PresencePayload { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { Ok(match (elem.name().as_ref(), elem.ns().unwrap().as_ref()) { @@ -214,7 +214,7 @@ impl Presence { } impl TryFrom for Presence { - type Error = Error; + type Err = Error; fn try_from(root: Element) -> Result { if !root.is("presence", ns::JABBER_CLIENT) { diff --git a/src/pubsub/event.rs b/src/pubsub/event.rs index 07e465c89a59dc3c7bdc3af520b1f787751dd588..ef5e994b8abb4471c07d78374e17e0a0eae660d7 100644 --- a/src/pubsub/event.rs +++ b/src/pubsub/event.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 std::convert::TryFrom; +use try_from::TryFrom; use std::str::FromStr; use minidom::{Element, IntoElements, IntoAttributeValue, ElementEmitter}; @@ -138,7 +138,7 @@ fn parse_items(elem: Element, node: String) -> Result { } impl TryFrom for PubSubEvent { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("event", ns::PUBSUB_EVENT) { diff --git a/src/receipts.rs b/src/receipts.rs index 72b357a1de277ef15308ed3704a6c0a58fe17cb7..ae564f747066bdb0b3ec0244abb5507d5b51245b 100644 --- a/src/receipts.rs +++ b/src/receipts.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 std::convert::TryFrom; +use try_from::TryFrom; use minidom::Element; @@ -19,7 +19,7 @@ pub enum Receipt { } impl TryFrom for Receipt { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { for _ in elem.children() { diff --git a/src/roster.rs b/src/roster.rs index db939ad8135ae537040af90125947eacdca36e4e..4e6a38c6d1bf9d6684db15746b6a56688adf50dc 100644 --- a/src/roster.rs +++ b/src/roster.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 std::convert::TryFrom; +use try_from::TryFrom; use std::str::FromStr; use minidom::{Element, IntoElements, IntoAttributeValue, ElementEmitter}; @@ -32,7 +32,7 @@ pub struct Item { } impl TryFrom for Item { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("item", ns::ROSTER) { @@ -83,7 +83,7 @@ pub struct Roster { } impl TryFrom for Roster { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("query", ns::ROSTER) { diff --git a/src/rsm.rs b/src/rsm.rs index e8d7109d8465dc7867077cfa0375bb5aa0ce2d05..cfb6f29243140d517ff9b07b3bbc93f3aa916d90 100644 --- a/src/rsm.rs +++ b/src/rsm.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 std::convert::TryFrom; +use try_from::TryFrom; use minidom::Element; @@ -25,7 +25,7 @@ pub struct Set { } impl TryFrom for Set { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("set", ns::RSM) { diff --git a/src/stanza_error.rs b/src/stanza_error.rs index badd1efab7606026dde90871142add5083bb35a7..c25c5792ec0ac234f3d9fc34f714dffa14ead38c 100644 --- a/src/stanza_error.rs +++ b/src/stanza_error.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 std::convert::TryFrom; +use try_from::TryFrom; use std::str::FromStr; use std::collections::BTreeMap; @@ -122,7 +122,7 @@ pub struct StanzaError { } impl TryFrom for StanzaError { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { if !elem.is("error", ns::JABBER_CLIENT) { diff --git a/src/stanza_id.rs b/src/stanza_id.rs index 38008d0c5c8230050c7a12c8f200e9dccebe88fc..634def50a063c0ecbc159e0012fe7df270c2bee1 100644 --- a/src/stanza_id.rs +++ b/src/stanza_id.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 std::convert::TryFrom; +use try_from::TryFrom; use minidom::Element; use jid::Jid; @@ -25,7 +25,7 @@ pub enum StanzaId { } impl TryFrom for StanzaId { - type Error = Error; + type Err = Error; fn try_from(elem: Element) -> Result { let is_stanza_id = elem.is("stanza-id", ns::SID);