From 2d55a22e738fb7f37a271be4fc3cf2ebdb9b5345 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Tue, 27 Jan 2015 18:07:23 -0800 Subject: [PATCH] feat(status): add is_() methods to StatusCodes --- src/status.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/status.rs b/src/status.rs index 0d6c6fbcd0..3e6db8bd93 100644 --- a/src/status.rs +++ b/src/status.rs @@ -1571,6 +1571,31 @@ impl StatusCode { StatusClass::ServerError } } + + /// Check if class is Informational. + pub fn is_informational(&self) -> bool { + self.class() == StatusClass::Informational + } + + /// Check if class is Success. + pub fn is_success(&self) -> bool { + self.class() == StatusClass::Success + } + + /// Check if class is Redirection. + pub fn is_redirection(&self) -> bool { + self.class() == StatusClass::Redirection + } + + /// Check if class is ClientError. + pub fn is_client_error(&self) -> bool { + self.class() == StatusClass::ClientError + } + + /// Check if class is ServerError. + pub fn is_server_error(&self) -> bool { + self.class() == StatusClass::ServerError + } } impl Copy for StatusCode {}