From 0c429cba9485e8f5efe9e51a8c088fcade93f35c Mon Sep 17 00:00:00 2001 From: Daniel Abramov Date: Sat, 28 Mar 2020 20:03:30 +0100 Subject: [PATCH] chore: remove deprecated `description()` Fixes #111 --- src/error.rs | 24 +++--------------------- src/handshake/mod.rs | 9 +-------- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/src/error.rs b/src/error.rs index ac2de26..ab24753 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,7 +1,6 @@ //! Error handling. -use std::borrow::{Borrow, Cow}; - +use std::borrow::Cow; use std::error::Error as ErrorTrait; use std::fmt; use std::io; @@ -89,24 +88,7 @@ impl fmt::Display for Error { } } -impl ErrorTrait for Error { - fn description(&self) -> &str { - match *self { - Error::ConnectionClosed => "A close handshake is performed", - Error::AlreadyClosed => "Trying to read or write after getting close notification", - Error::Io(ref err) => err.description(), - #[cfg(feature = "tls")] - Error::Tls(ref err) => err.description(), - Error::Capacity(ref msg) => msg.borrow(), - Error::Protocol(ref msg) => msg.borrow(), - Error::SendQueueFull(_) => "Send queue is full", - Error::Utf8 => "", - Error::Url(ref msg) => msg.borrow(), - Error::Http(_) => "", - Error::HttpFormat(ref err) => err.description(), - } - } -} +impl ErrorTrait for Error {} impl From for Error { fn from(err: io::Error) -> Self { @@ -173,7 +155,7 @@ impl From for Error { fn from(err: httparse::Error) -> Self { match err { httparse::Error::TooManyHeaders => Error::Capacity("Too many headers".into()), - e => Error::Protocol(Cow::Owned(e.description().into())), + e => Error::Protocol(e.to_string().into()), } } } diff --git a/src/handshake/mod.rs b/src/handshake/mod.rs index 828de65..3983690 100644 --- a/src/handshake/mod.rs +++ b/src/handshake/mod.rs @@ -81,14 +81,7 @@ impl fmt::Display for HandshakeError { } } -impl ErrorTrait for HandshakeError { - fn description(&self) -> &str { - match *self { - HandshakeError::Interrupted(_) => "Interrupted handshake", - HandshakeError::Failure(ref e) => e.description(), - } - } -} +impl ErrorTrait for HandshakeError {} impl From for HandshakeError { fn from(err: Error) -> Self {