pub struct Response { /* private fields */ }
Expand description
Represents an HTTP response
Implementations§
source§impl Response
impl Response
Creates a new blank Response
.
sourcepub fn headers(&self) -> &HeaderMap<HeaderValue>
pub fn headers(&self) -> &HeaderMap<HeaderValue>
Get headers reference.
sourcepub fn headers_mut(&mut self) -> &mut HeaderMap<HeaderValue>
pub fn headers_mut(&mut self) -> &mut HeaderMap<HeaderValue>
Get mutable headers reference.
sourcepub fn set_headers(&mut self, headers: HeaderMap<HeaderValue>)
pub fn set_headers(&mut self, headers: HeaderMap<HeaderValue>)
Sets headers.
sourcepub fn add_header<N, V>(
&mut self,
name: N,
value: V,
overwrite: bool
) -> Result<(), Error>where
N: IntoHeaderName,
V: TryInto<HeaderValue>,
pub fn add_header<N, V>(
&mut self,
name: N,
value: V,
overwrite: bool
) -> Result<(), Error>where
N: IntoHeaderName,
V: TryInto<HeaderValue>,
Modify a header for this response.
When overwrite
is set to true
, If the header is already present, the value will be replaced.
When overwrite
is set to false
, The new header is always appended to the request, even if the header already exists.
sourcepub fn with_header<N, V>(
&mut self,
name: N,
value: V,
overwrite: bool
) -> Result<&mut Response, Error>where
N: IntoHeaderName,
V: TryInto<HeaderValue>,
pub fn with_header<N, V>(
&mut self,
name: N,
value: V,
overwrite: bool
) -> Result<&mut Response, Error>where
N: IntoHeaderName,
V: TryInto<HeaderValue>,
Modify a header for this response.
When overwrite
is set to true
, If the header is already present, the value will be replaced.
When overwrite
is set to false
, The new header is always appended to the request, even if the header already exists.
sourcepub fn version_mut(&mut self) -> &mut Version
pub fn version_mut(&mut self) -> &mut Version
Get mutable version reference.
sourcepub fn replace_body(&mut self, body: ResBody) -> ResBody
pub fn replace_body(&mut self, body: ResBody) -> ResBody
Sets body to a new value and returns old value.
Get cookies reference.
Get mutable cookies reference.
Helper function for get cookie.
Helper function for add cookie.
Helper function for add cookie.
Helper function for remove cookie.
Removes cookie
from this CookieJar. If an original cookie with the same
name as cookie
is present in the jar, a removal cookie will be
present in the delta
computation.
A “removal” cookie is a cookie that has the same name as the original cookie but has an empty value, a max-age of 0, and an expiration date far in the past. Read more about removal cookies.
sourcepub fn status_code(&self) -> Option<StatusCode>
pub fn status_code(&self) -> Option<StatusCode>
Get status code.
sourcepub fn set_status_code(&mut self, code: StatusCode)
pub fn set_status_code(&mut self, code: StatusCode)
Sets status code.
sourcepub fn with_status_code(&mut self, code: StatusCode) -> &mut Response
pub fn with_status_code(&mut self, code: StatusCode) -> &mut Response
Sets status code.
sourcepub fn content_type(&self) -> Option<Mime>
pub fn content_type(&self) -> Option<Mime>
Get content type.
sourcepub fn status_error(&self) -> Option<&StatusError>
pub fn status_error(&self) -> Option<&StatusError>
Get http error if exists, only exists after use set_status_error
set http error.
sourcepub fn set_status_error(&mut self, err: StatusError)
pub fn set_status_error(&mut self, err: StatusError)
Sets http error.
sourcepub fn with_status_error(&mut self, err: StatusError) -> &mut Response
pub fn with_status_error(&mut self, err: StatusError) -> &mut Response
Sets http error.
sourcepub fn with_render<P>(&mut self, piece: P) -> &mut Responsewhere
P: Piece,
pub fn with_render<P>(&mut self, piece: P) -> &mut Responsewhere
P: Piece,
Render content.
sourcepub fn stuff<P>(&mut self, code: StatusCode, piece: P)where
P: Piece,
pub fn stuff<P>(&mut self, code: StatusCode, piece: P)where
P: Piece,
Render content with status code.
sourcepub fn with_stuff<P>(&mut self, code: StatusCode, piece: P) -> &mut Responsewhere
P: Piece,
pub fn with_stuff<P>(&mut self, code: StatusCode, piece: P) -> &mut Responsewhere
P: Piece,
Render content with status code.
Trait Implementations§
source§impl ResponseExt for Response
impl ResponseExt for Response
source§fn take_string<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Response: 'async_trait,
fn take_string<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Response: 'async_trait,
String
from response.source§fn take_json<'life0, 'async_trait, T>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
T: 'async_trait + DeserializeOwned,
Response: 'async_trait,
fn take_json<'life0, 'async_trait, T>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
T: 'async_trait + DeserializeOwned,
Response: 'async_trait,
T
instance.source§fn take_string_with_charset<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
charset: &'life1 str,
compress: Option<&'life2 str>
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Response: 'async_trait,
fn take_string_with_charset<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
charset: &'life1 str,
compress: Option<&'life2 str>
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Response: 'async_trait,
String
from response with charset.