Remove failure.

This commit is contained in:
Emmanuel Gil Peyrot 2019-09-05 18:42:22 +02:00
parent bf1c2bd48b
commit cba7a31ea0
2 changed files with 12 additions and 10 deletions

View file

@ -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 }

View file

@ -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 {