pub struct Response { /* private fields */ }
Expand description
Represents an HTTP response
Implementations
sourceimpl Response
impl Response
sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Get mutable headers reference.
sourcepub fn set_headers(&mut self, headers: HeaderMap)
pub fn set_headers(&mut self, headers: HeaderMap)
Set headers.
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: Body) -> Body
pub fn replace_body(&mut self, body: Body) -> Body
Set 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 remove cookie.
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)
Set 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)
Set http error.
sourcepub fn render<P>(&mut self, piece: P) where
P: Piece,
pub fn render<P>(&mut self, piece: P) where
P: Piece,
Render text as html content. It will set content-type
to text/html; charset=utf-8
.
sourcepub fn write_body(&mut self, data: &[u8]) -> Result<()>
pub fn write_body(&mut self, data: &[u8]) -> Result<()>
Write bytes data to body. If body is none, a new Body
will created.
sourcepub fn streaming<S, O, E>(&mut self, stream: S) -> Result<()> where
S: Stream<Item = Result<O, E>> + Send + 'static,
O: Into<Bytes> + 'static,
E: Into<Box<dyn StdError + Send + Sync>> + 'static,
pub fn streaming<S, O, E>(&mut self, stream: S) -> Result<()> where
S: Stream<Item = Result<O, E>> + Send + 'static,
O: Into<Bytes> + 'static,
E: Into<Box<dyn StdError + Send + Sync>> + 'static,
Write streaming data.
sourcepub fn redirect_temporary<U: AsRef<str>>(&mut self, url: U)
pub fn redirect_temporary<U: AsRef<str>>(&mut self, url: U)
Redirect temporary.
sourcepub fn redirect_found<U: AsRef<str>>(&mut self, url: U)
pub fn redirect_found<U: AsRef<str>>(&mut self, url: U)
Redirect found.
sourcepub fn redirect_other<U: AsRef<str>>(
&mut self,
url: U
) -> Result<(), InvalidHeaderValue>
pub fn redirect_other<U: AsRef<str>>(
&mut self,
url: U
) -> Result<(), InvalidHeaderValue>
Redirect other.
Trait Implementations
sourceimpl ResponseExt for Response
Available on crate feature test
only.
impl ResponseExt for Response
test
only.sourcefn take_string<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn take_string<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Take body as String
from response.
sourcefn take_json<'life0, 'async_trait, T>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>> where
T: 'async_trait + DeserializeOwned,
'life0: 'async_trait,
Self: 'async_trait,
fn take_json<'life0, 'async_trait, T>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>> where
T: 'async_trait + DeserializeOwned,
'life0: 'async_trait,
Self: 'async_trait,
Take body as deserialize it to type T
instance.
sourcefn 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>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: '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>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Take body as String
from response with charset.
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more