Skip to content

Commit

Permalink
feat(status): add is_<status_class>() methods to StatusCodes
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Jan 28, 2015
1 parent bdc2ee2 commit 2d55a22
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down

0 comments on commit 2d55a22

Please sign in to comment.