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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
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