@@ -10,17 +10,6 @@ use std::cmp::Ordering;
1010/// recommended to only use values between [100, 599], since only these are
1111/// defined as valid status codes with a status class by HTTP.
1212///
13- /// If you encounter a status code that you do not know how to deal with, you
14- /// should treat it as the `x00` status code—e.g. for code 123, treat it as
15- /// 100 (Continue). This can be achieved with
16- /// `self.class().default_code()`:
17- ///
18- /// ```rust
19- /// # use hyper::status::StatusCode;
20- /// let status = StatusCode::Unregistered(123);
21- /// assert_eq!(status.class().default_code(), StatusCode::Continue);
22- /// ```
23- ///
2413/// IANA maintain the [Hypertext Transfer Protocol (HTTP) Status Code
2514/// Registry](http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml) which is
2615/// the source for this enum (with one exception, 418 I'm a teapot, which is
@@ -448,52 +437,38 @@ impl StatusCode {
448437 }
449438 }
450439
451- /// Determine the class of a status code, based on its first digit.
452- #[ deprecated( note = "StatusClass is going away. Use the is_<class>() methods instead." ) ]
453- #[ allow( deprecated) ]
454- pub fn class ( & self ) -> StatusClass {
455- match self . to_u16 ( ) {
456- 100 ...199 => StatusClass :: Informational ,
457- 200 ...299 => StatusClass :: Success ,
458- 300 ...399 => StatusClass :: Redirection ,
459- 400 ...499 => StatusClass :: ClientError ,
460- 500 ...599 => StatusClass :: ServerError ,
461- _ => StatusClass :: NoClass ,
462- }
463- }
464-
465- /// Check if class is Informational.
466- #[ allow( deprecated) ]
440+ /// Check if this `StatusCode` is within 100-199.
441+ #[ inline]
467442 pub fn is_informational ( & self ) -> bool {
468443 self . class ( ) == StatusClass :: Informational
469444 }
470445
471- /// Check if class is Success .
472- #[ allow ( deprecated ) ]
446+ /// Check if this `StatusCode` is within 200-299 .
447+ #[ inline ]
473448 pub fn is_success ( & self ) -> bool {
474449 self . class ( ) == StatusClass :: Success
475450 }
476451
477- /// Check if class is Redirection .
478- #[ allow ( deprecated ) ]
452+ /// Check if this `StatusCode` is within 300-399 .
453+ #[ inline ]
479454 pub fn is_redirection ( & self ) -> bool {
480455 self . class ( ) == StatusClass :: Redirection
481456 }
482457
483- /// Check if class is ClientError .
484- #[ allow ( deprecated ) ]
458+ /// Check if this `StatusCode` is within 400-499 .
459+ #[ inline ]
485460 pub fn is_client_error ( & self ) -> bool {
486461 self . class ( ) == StatusClass :: ClientError
487462 }
488463
489- /// Check if class is ServerError .
490- #[ allow ( deprecated ) ]
464+ /// Check if this `StatusCode` is within 500-599 .
465+ #[ inline ]
491466 pub fn is_server_error ( & self ) -> bool {
492467 self . class ( ) == StatusClass :: ServerError
493468 }
494469
495- /// Check if class is NoClass
496- #[ allow ( deprecated ) ]
470+ /// Check if this `StatusCode` is not within 100-599.
471+ #[ inline ]
497472 pub fn is_strange_status ( & self ) -> bool {
498473 self . class ( ) == StatusClass :: NoClass
499474 }
@@ -590,9 +565,7 @@ impl From<StatusCode> for u16 {
590565/// This can be used in cases where a status code’s meaning is unknown, also,
591566/// to get the appropriate *category* of status.
592567#[ derive( Debug , Clone , PartialEq , Eq , PartialOrd , Ord , Copy ) ]
593- #[ deprecated( note = "StatusClass is going away. Use the StatusCode::is_<class>() methods instead." ) ]
594- #[ allow( deprecated) ]
595- pub enum StatusClass {
568+ enum StatusClass {
596569 /// 1xx (Informational): The request was received, continuing process
597570 Informational ,
598571
@@ -612,7 +585,6 @@ pub enum StatusClass {
612585 NoClass ,
613586}
614587
615- #[ allow( deprecated) ]
616588impl StatusClass {
617589 /// Get the default status code for the class.
618590 ///
@@ -683,7 +655,6 @@ mod tests {
683655 // - status code
684656 // - default code (for the given status code)
685657 // - canonical reason
686- #[ allow( deprecated) ]
687658 fn validate ( num : u16 , status_code : StatusCode , default_code : StatusCode , reason : Option < & str > ) {
688659 assert_eq ! ( StatusCode :: from_u16( num) , status_code) ;
689660 assert_eq ! ( status_code. to_u16( ) , num) ;
0 commit comments