Skip to content

Commit 2d55a22

Browse files
committed
feat(status): add is_<status_class>() methods to StatusCodes
1 parent bdc2ee2 commit 2d55a22

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/status.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,6 +1571,31 @@ impl StatusCode {
15711571
StatusClass::ServerError
15721572
}
15731573
}
1574+
1575+
/// Check if class is Informational.
1576+
pub fn is_informational(&self) -> bool {
1577+
self.class() == StatusClass::Informational
1578+
}
1579+
1580+
/// Check if class is Success.
1581+
pub fn is_success(&self) -> bool {
1582+
self.class() == StatusClass::Success
1583+
}
1584+
1585+
/// Check if class is Redirection.
1586+
pub fn is_redirection(&self) -> bool {
1587+
self.class() == StatusClass::Redirection
1588+
}
1589+
1590+
/// Check if class is ClientError.
1591+
pub fn is_client_error(&self) -> bool {
1592+
self.class() == StatusClass::ClientError
1593+
}
1594+
1595+
/// Check if class is ServerError.
1596+
pub fn is_server_error(&self) -> bool {
1597+
self.class() == StatusClass::ServerError
1598+
}
15741599
}
15751600

15761601
impl Copy for StatusCode {}

0 commit comments

Comments
 (0)