From cba7a31ea0ec64c03acb8fca20df08c8f0e4c9fb Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 5 Sep 2019 18:42:22 +0200 Subject: [PATCH] Remove failure. --- Cargo.toml | 2 -- src/lib.rs | 20 ++++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 77cbae3d..162cb9a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,4 @@ edition = "2018" gitlab = { repository = "xmpp-rs/jid-rs" } [dependencies] -failure = "0.1.1" -failure_derive = "0.1.1" minidom = { version = "0.11", optional = true } diff --git a/src/lib.rs b/src/lib.rs index c55c8067..948576c3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,34 +14,38 @@ //! //! For usage, check the documentation on the `Jid` struct. -#[macro_use] -extern crate failure_derive; - use std::convert::Into; use std::fmt; use std::str::FromStr; /// An error that signifies that a `Jid` cannot be parsed from a string. -#[derive(Debug, Clone, PartialEq, Eq, Fail)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum JidParseError { /// Happens when there is no domain, that is either the string is empty, /// starts with a /, or contains the @/ sequence. - #[fail(display = "no domain found in this JID")] NoDomain, /// Happens when there is no resource, that is string contains no /. - #[fail(display = "no resource found in this full JID")] NoResource, /// Happens when the node is empty, that is the string starts with a @. - #[fail(display = "nodepart empty despite the presence of a @")] EmptyNode, /// Happens when the resource is empty, that is the string ends with a /. - #[fail(display = "resource empty despite the presence of a /")] EmptyResource, } +impl fmt::Display for JidParseError { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + write!(fmt, "{}", match self { + JidParseError::NoDomain => "no domain found in this JID", + JidParseError::NoResource => "no resource found in this full JID", + JidParseError::EmptyNode => "nodepart empty despite the presence of a @", + JidParseError::EmptyResource => "resource empty despite the presence of a /", + }) + } +} + /// An enum representing a Jabber ID. It can be either a `FullJid` or a `BareJid`. #[derive(Debug, Clone, PartialEq)] pub enum Jid {