@@ -10,17 +10,6 @@ use std::cmp::Ordering;
10
10
/// recommended to only use values between [100, 599], since only these are
11
11
/// defined as valid status codes with a status class by HTTP.
12
12
///
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
- ///
24
13
/// IANA maintain the [Hypertext Transfer Protocol (HTTP) Status Code
25
14
/// Registry](http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml) which is
26
15
/// the source for this enum (with one exception, 418 I'm a teapot, which is
@@ -448,52 +437,38 @@ impl StatusCode {
448
437
}
449
438
}
450
439
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]
467
442
pub fn is_informational ( & self ) -> bool {
468
443
self . class ( ) == StatusClass :: Informational
469
444
}
470
445
471
- /// Check if class is Success .
472
- #[ allow ( deprecated ) ]
446
+ /// Check if this `StatusCode` is within 200-299 .
447
+ #[ inline ]
473
448
pub fn is_success ( & self ) -> bool {
474
449
self . class ( ) == StatusClass :: Success
475
450
}
476
451
477
- /// Check if class is Redirection .
478
- #[ allow ( deprecated ) ]
452
+ /// Check if this `StatusCode` is within 300-399 .
453
+ #[ inline ]
479
454
pub fn is_redirection ( & self ) -> bool {
480
455
self . class ( ) == StatusClass :: Redirection
481
456
}
482
457
483
- /// Check if class is ClientError .
484
- #[ allow ( deprecated ) ]
458
+ /// Check if this `StatusCode` is within 400-499 .
459
+ #[ inline ]
485
460
pub fn is_client_error ( & self ) -> bool {
486
461
self . class ( ) == StatusClass :: ClientError
487
462
}
488
463
489
- /// Check if class is ServerError .
490
- #[ allow ( deprecated ) ]
464
+ /// Check if this `StatusCode` is within 500-599 .
465
+ #[ inline ]
491
466
pub fn is_server_error ( & self ) -> bool {
492
467
self . class ( ) == StatusClass :: ServerError
493
468
}
494
469
495
- /// Check if class is NoClass
496
- #[ allow ( deprecated ) ]
470
+ /// Check if this `StatusCode` is not within 100-599.
471
+ #[ inline ]
497
472
pub fn is_strange_status ( & self ) -> bool {
498
473
self . class ( ) == StatusClass :: NoClass
499
474
}
@@ -590,9 +565,7 @@ impl From<StatusCode> for u16 {
590
565
/// This can be used in cases where a status code’s meaning is unknown, also,
591
566
/// to get the appropriate *category* of status.
592
567
#[ 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 {
596
569
/// 1xx (Informational): The request was received, continuing process
597
570
Informational ,
598
571
@@ -612,7 +585,6 @@ pub enum StatusClass {
612
585
NoClass ,
613
586
}
614
587
615
- #[ allow( deprecated) ]
616
588
impl StatusClass {
617
589
/// Get the default status code for the class.
618
590
///
@@ -683,7 +655,6 @@ mod tests {
683
655
// - status code
684
656
// - default code (for the given status code)
685
657
// - canonical reason
686
- #[ allow( deprecated) ]
687
658
fn validate ( num : u16 , status_code : StatusCode , default_code : StatusCode , reason : Option < & str > ) {
688
659
assert_eq ! ( StatusCode :: from_u16( num) , status_code) ;
689
660
assert_eq ! ( status_code. to_u16( ) , num) ;
0 commit comments