Add some explicit conversion methods

This commit is contained in:
Alex Crichton
2017-07-26 12:38:57 -07:00
parent df77f28998
commit 890b2d7913
2 changed files with 20 additions and 0 deletions
+5
View File
@@ -61,6 +61,11 @@ impl StatusCode {
Ok(StatusCode(status))
}
/// Returns the u16 corresponding to this status code
pub fn as_u16(&self) -> u16 {
(*self).into()
}
/// Check if class is Informational.
pub fn is_informational(&self) -> bool {
200 > self.0 && self.0 >= 100
+15
View File
@@ -711,6 +711,11 @@ impl Scheme {
None => unreachable!(),
}
}
/// Converts this `Scheme` back to a sequence of bytes
pub fn into_bytes(self) -> Bytes {
self.into()
}
}
impl FromStr for Scheme {
@@ -922,6 +927,11 @@ impl Authority {
pub fn as_str(&self) -> &str {
&self.data[..]
}
/// Converts this `Authority` back to a sequence of bytes
pub fn into_bytes(self) -> Bytes {
self.into()
}
}
impl FromStr for Authority {
@@ -1096,6 +1106,11 @@ impl OriginForm {
Some(&self.data[i as usize..])
}
}
/// Converts this `OriginForm` back to a sequence of bytes
pub fn into_bytes(self) -> Bytes {
self.into()
}
}
impl FromStr for OriginForm {