refactor(http): add status() methods to RawStatus and ResponseHead
This lets us convert RawStatus to StatusCode in Response without having to address the tuple index directly.
This commit is contained in:
		| @@ -71,10 +71,26 @@ impl<S> MessageHead<S> { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | impl ResponseHead { | ||||||
|  |     /// Converts this head's RawStatus into a StatusCode. | ||||||
|  |     #[inline] | ||||||
|  |     pub fn status(&self) -> StatusCode { | ||||||
|  |         self.subject.status() | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| /// The raw status code and reason-phrase. | /// The raw status code and reason-phrase. | ||||||
| #[derive(Clone, PartialEq, Debug)] | #[derive(Clone, PartialEq, Debug)] | ||||||
| pub struct RawStatus(pub u16, pub Cow<'static, str>); | pub struct RawStatus(pub u16, pub Cow<'static, str>); | ||||||
|  |  | ||||||
|  | impl RawStatus { | ||||||
|  |     /// Converts this into a StatusCode. | ||||||
|  |     #[inline] | ||||||
|  |     pub fn status(&self) -> StatusCode { | ||||||
|  |         StatusCode::from_u16(self.0) | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| impl fmt::Display for RawStatus { | impl fmt::Display for RawStatus { | ||||||
|     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||||||
|         write!(f, "{} {}", self.0, self.1) |         write!(f, "{} {}", self.0, self.1) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user