pub struct ReasonPhrase(/* private fields */);
Expand description
A reason phrase in an HTTP/1 response.
§Clients
For clients, a ReasonPhrase
will be present in the extensions of the http::Response
returned
for a request if the reason phrase is different from the canonical reason phrase for the
response’s status code. For example, if a server returns HTTP/1.1 200 Awesome
, the
ReasonPhrase
will be present and contain Awesome
, but if a server returns HTTP/1.1 200 OK
,
the response will not contain a ReasonPhrase
.
use hyper::{Client, Uri};
use hyper::ext::ReasonPhrase;
let res = Client::new().get(Uri::from_static("http://example.com/non_canonical_reason")).await?;
// Print out the non-canonical reason phrase, if it has one...
if let Some(reason) = res.extensions().get::<ReasonPhrase>() {
println!("non-canonical reason: {}", std::str::from_utf8(reason.as_bytes()).unwrap());
}
§Servers
When a ReasonPhrase
is present in the extensions of the http::Response
written by a server,
its contents will be written in place of the canonical reason phrase when responding via HTTP/1.
Implementations§
Source§impl ReasonPhrase
impl ReasonPhrase
Trait Implementations§
Source§impl AsRef<[u8]> for ReasonPhrase
impl AsRef<[u8]> for ReasonPhrase
Source§impl Clone for ReasonPhrase
impl Clone for ReasonPhrase
Source§fn clone(&self) -> ReasonPhrase
fn clone(&self) -> ReasonPhrase
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ReasonPhrase
impl Debug for ReasonPhrase
Source§impl From<ReasonPhrase> for Bytes
impl From<ReasonPhrase> for Bytes
Source§fn from(reason: ReasonPhrase) -> Self
fn from(reason: ReasonPhrase) -> Self
Source§impl Hash for ReasonPhrase
impl Hash for ReasonPhrase
Source§impl Ord for ReasonPhrase
impl Ord for ReasonPhrase
Source§fn cmp(&self, other: &ReasonPhrase) -> Ordering
fn cmp(&self, other: &ReasonPhrase) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ReasonPhrase
impl PartialEq for ReasonPhrase
Source§impl PartialOrd for ReasonPhrase
impl PartialOrd for ReasonPhrase
Source§impl TryFrom<&[u8]> for ReasonPhrase
impl TryFrom<&[u8]> for ReasonPhrase
Source§impl TryFrom<Bytes> for ReasonPhrase
impl TryFrom<Bytes> for ReasonPhrase
Source§impl TryFrom<String> for ReasonPhrase
impl TryFrom<String> for ReasonPhrase
impl Eq for ReasonPhrase
impl StructuralPartialEq for ReasonPhrase
Auto Trait Implementations§
impl !Freeze for ReasonPhrase
impl RefUnwindSafe for ReasonPhrase
impl Send for ReasonPhrase
impl Sync for ReasonPhrase
impl Unpin for ReasonPhrase
impl UnwindSafe for ReasonPhrase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes