From 01f64983559602b9ebaaeecf6d33e97a88185676 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Thu, 29 Nov 2018 16:14:24 -0800 Subject: [PATCH] feat(error): add `Error::is_connect` method This allows inspecting errors to determine if they are from a client trying to establish a connection (from the `Connect`). --- src/error.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/error.rs b/src/error.rs index d79b6f4376..226dee4a4d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -97,13 +97,6 @@ pub(crate) enum User { */ impl Error { - //TODO(error): should there be these kinds of inspection methods? - // - // - is_io() - // - is_connect() - // - is_closed() - // - etc? - /// Returns true if this was an HTTP parse error. pub fn is_parse(&self) -> bool { match self.inner.kind { @@ -139,6 +132,11 @@ impl Error { self.inner.kind == Kind::Closed } + /// Returns true if this was an error from `Connect`. + pub fn is_connect(&self) -> bool { + self.inner.kind == Kind::Connect + } + /// Returns the error's cause. /// /// This is identical to `Error::cause` except that it provides extra