mirror of
https://github.com/openharmony/third_party_rust_http.git
synced 2026-07-19 14:43:33 -04:00
Add some explicit conversion methods
This commit is contained in:
@@ -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
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user