From 638582fae290469480067d72cb4bf9492d98900d Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Thu, 11 May 2017 12:46:46 -0700 Subject: [PATCH] refactor(status): deprecate StatusClass --- src/status.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/status.rs b/src/status.rs index cbab52a8..52a57233 100644 --- a/src/status.rs +++ b/src/status.rs @@ -449,6 +449,8 @@ impl StatusCode { } /// Determine the class of a status code, based on its first digit. + #[deprecated(note = "StatusClass is going away. Use the is_() methods instead.")] + #[allow(deprecated)] pub fn class(&self) -> StatusClass { match self.to_u16() { 100...199 => StatusClass::Informational, @@ -461,31 +463,37 @@ impl StatusCode { } /// Check if class is Informational. + #[allow(deprecated)] pub fn is_informational(&self) -> bool { self.class() == StatusClass::Informational } /// Check if class is Success. + #[allow(deprecated)] pub fn is_success(&self) -> bool { self.class() == StatusClass::Success } /// Check if class is Redirection. + #[allow(deprecated)] pub fn is_redirection(&self) -> bool { self.class() == StatusClass::Redirection } /// Check if class is ClientError. + #[allow(deprecated)] pub fn is_client_error(&self) -> bool { self.class() == StatusClass::ClientError } /// Check if class is ServerError. + #[allow(deprecated)] pub fn is_server_error(&self) -> bool { self.class() == StatusClass::ServerError } /// Check if class is NoClass + #[allow(deprecated)] pub fn is_strange_status(&self) -> bool { self.class() == StatusClass::NoClass } @@ -582,6 +590,7 @@ impl From for u16 { /// This can be used in cases where a status code’s meaning is unknown, also, /// to get the appropriate *category* of status. #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Copy)] +#[deprecated(note = "StatusClass is going away. Use the StatusCode::is_() methods instead.")] pub enum StatusClass { /// 1xx (Informational): The request was received, continuing process Informational, @@ -602,6 +611,7 @@ pub enum StatusClass { NoClass, } +#[allow(deprecated)] impl StatusClass { /// Get the default status code for the class. /// @@ -672,6 +682,7 @@ mod tests { // - status code // - default code (for the given status code) // - canonical reason + #[allow(deprecated)] fn validate(num: u16, status_code: StatusCode, default_code: StatusCode, reason: Option<&str>) { assert_eq!(StatusCode::from_u16(num), status_code); assert_eq!(status_code.to_u16(), num);