[−][src]Struct yukikaze::client::response::Response
HTTP Response
Implementations
impl Response
[src]
pub fn new(hyper: Response<Body>) -> Self
[src]
Creates new instance from existing hyper response.
pub fn status(&self) -> StatusCode
[src]
Retrieves status code
pub fn is_info(&self) -> bool
[src]
Returns whether Response's status is informational.
The response status code is in range 100 to 199
pub fn is_success(&self) -> bool
[src]
Returns whether Response's status is successful.
The response status code is in range 200 to 299
pub fn is_redirect(&self) -> bool
[src]
Returns whether Response's status is re-directional.
The response status code is in range 300 to 399
pub fn is_error(&self) -> bool
[src]
Returns whether Response's status is error.
The response status code is in range 400 to 599
pub fn is_client_error(&self) -> bool
[src]
Returns whether Response's status is error caused by client.
The response status code is in range 400 to 499
pub fn is_internal_error(&self) -> bool
[src]
Returns whether Response's status is error caused by server.
The response status code is in range 500 to 599
pub fn is_upgrade(&self) -> bool
[src]
Returns whether Response's status indicates upgrade
pub fn extensions(&self) -> &Extensions
[src]
Retrieves reference to http extension map
pub fn extensions_mut(&mut self) -> &mut Extensions
[src]
Retrieves mutable reference to http extension map
pub fn headers(&self) -> &HeaderMap
[src]
Access response's headers
pub fn mime(&self) -> Result<Option<Mime>, ContentTypeError>
[src]
Retrieves Content-Type
as Mime, if any.
pub fn charset_encoding(&self) -> Result<&'static Encoding, ContentTypeError>
[src]
Retrieves content's charset encoding, if any.
If it is omitted, UTF-8 is assumed.
pub fn content_len(&self) -> Option<usize>
[src]
Retrieves length of content to receive, if Content-Length
exists.
pub fn content_encoding(&self) -> ContentEncoding
[src]
Retrieves Content-Encoding
, if header is not present ContentEncoding::Idenity
is
assumed.
pub fn content_disposition(&self) -> Option<ContentDisposition>
[src]
Retrieves Content-Disposition
, if it valid one is present.
pub fn cookies_iter(&self) -> CookieIter
[src]
Creates iterator of cookie from Set-Cookie
header.
pub fn cookies_jar(&self) -> Result<CookieJar, ParseError>
[src]
Creates jar from cookies in response.
pub fn cookies(&self) -> Result<Vec<Cookie<'static>>, ParseError>
[src]
Retrieves all cookies from Set-Cookie
headers.
pub fn last_modified(&self) -> Option<HttpDate>
[src]
Extracts Last-Modified
date, if valid one is present.
pub fn etag(&self) -> Option<EntityTag>
[src]
Extracts Etags, if any.
pub fn extract_body(&mut self) -> (ContentEncoding, Option<usize>, Body)
[src]
Extracts hyper's body out of Response.
Returns Content encoding, Length, if specified, and body itself.
pub fn body(&mut self) -> impl Future<Output = Result<Bytes, BodyReadError>>
[src]
Extracts Response's body as raw bytes.
pub fn text(&mut self) -> impl Future<Output = Result<String, BodyReadError>>
[src]
Extracts Response's body as text
pub fn json<J: DeserializeOwned>(
&mut self
) -> impl Future<Output = Result<J, BodyReadError>>
[src]
&mut self
) -> impl Future<Output = Result<J, BodyReadError>>
Extracts Response's body as JSON
pub fn file(
&mut self,
file: File
) -> impl Future<Output = Result<File, BodyReadError>>
[src]
&mut self,
file: File
) -> impl Future<Output = Result<File, BodyReadError>>
Extracts Response's body into file
pub fn body_notify<N: Notifier>(
&mut self,
notify: N
) -> impl Future<Output = Result<Bytes, BodyReadError>>
[src]
&mut self,
notify: N
) -> impl Future<Output = Result<Bytes, BodyReadError>>
Extracts Response's body as raw bytes.
pub fn text_notify<N: Notifier>(
&mut self,
notify: N
) -> impl Future<Output = Result<String, BodyReadError>>
[src]
&mut self,
notify: N
) -> impl Future<Output = Result<String, BodyReadError>>
Extracts Response's body as text
pub fn json_notify<N: Notifier, J: DeserializeOwned>(
&mut self,
notify: N
) -> impl Future<Output = Result<J, BodyReadError>>
[src]
&mut self,
notify: N
) -> impl Future<Output = Result<J, BodyReadError>>
Extracts Response's body as JSON
pub fn file_notify<N: Notifier>(
&mut self,
file: File,
notify: N
) -> impl Future<Output = Result<File, BodyReadError>>
[src]
&mut self,
file: File,
notify: N
) -> impl Future<Output = Result<File, BodyReadError>>
Extracts Response's body into file
pub async fn upgrade<U: Upgrade>(
self,
__arg1: U
) -> Result<Result<(Self, Upgraded), Error>, U::VerifyError>
[src]
self,
__arg1: U
) -> Result<Result<(Self, Upgraded), Error>, U::VerifyError>
Prepares upgrade for the request.
Methods from Deref<Target = Response<Body>>
pub fn status(&self) -> StatusCode
[src]
Returns the StatusCode
.
Examples
let response: Response<()> = Response::default(); assert_eq!(response.status(), StatusCode::OK);
pub fn status_mut(&mut self) -> &mut StatusCode
[src]
Returns a mutable reference to the associated StatusCode
.
Examples
let mut response: Response<()> = Response::default(); *response.status_mut() = StatusCode::CREATED; assert_eq!(response.status(), StatusCode::CREATED);
pub fn version(&self) -> Version
[src]
Returns a reference to the associated version.
Examples
let response: Response<()> = Response::default(); assert_eq!(response.version(), Version::HTTP_11);
pub fn version_mut(&mut self) -> &mut Version
[src]
Returns a mutable reference to the associated version.
Examples
let mut response: Response<()> = Response::default(); *response.version_mut() = Version::HTTP_2; assert_eq!(response.version(), Version::HTTP_2);
pub fn headers(&self) -> &HeaderMap<HeaderValue>
[src]
Returns a reference to the associated header field map.
Examples
let response: Response<()> = Response::default(); assert!(response.headers().is_empty());
pub fn headers_mut(&mut self) -> &mut HeaderMap<HeaderValue>
[src]
Returns a mutable reference to the associated header field map.
Examples
let mut response: Response<()> = Response::default(); response.headers_mut().insert(HOST, HeaderValue::from_static("world")); assert!(!response.headers().is_empty());
pub fn extensions(&self) -> &Extensions
[src]
Returns a reference to the associated extensions.
Examples
let response: Response<()> = Response::default(); assert!(response.extensions().get::<i32>().is_none());
pub fn extensions_mut(&mut self) -> &mut Extensions
[src]
Returns a mutable reference to the associated extensions.
Examples
let mut response: Response<()> = Response::default(); response.extensions_mut().insert("hello"); assert_eq!(response.extensions().get(), Some(&"hello"));
pub fn body(&self) -> &T
[src]
Returns a reference to the associated HTTP body.
Examples
let response: Response<String> = Response::default(); assert!(response.body().is_empty());
pub fn body_mut(&mut self) -> &mut T
[src]
Returns a mutable reference to the associated HTTP body.
Examples
let mut response: Response<String> = Response::default(); response.body_mut().push_str("hello world"); assert!(!response.body().is_empty());
Trait Implementations
impl Debug for Response
[src]
impl Deref for Response
[src]
type Target = Response<Body>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl DerefMut for Response
[src]
impl From<Response<Body>> for Response
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl !UnwindSafe for Response
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> Sealed<T> for T where
T: ?Sized,
T: ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,