pub struct Response { /* private fields */ }
Expand description
A unified response object that can represent both outgoing and incoming responses.
This should be used in favor of OutgoingResponse
and IncomingResponse
when there
is no need for streaming bodies.
Implementations§
Source§impl Response
impl Response
Sourcepub fn new(status: impl IntoStatusCode, body: impl IntoBody) -> Self
pub fn new(status: impl IntoStatusCode, body: impl IntoBody) -> Self
Create a new response from a status and body
Sourcepub fn status(&self) -> &StatusCode
pub fn status(&self) -> &StatusCode
The response status
Sourcepub fn headers(&self) -> impl Iterator<Item = (&str, &HeaderValue)>
pub fn headers(&self) -> impl Iterator<Item = (&str, &HeaderValue)>
The request headers
Sourcepub fn header(&self, name: &str) -> Option<&HeaderValue>
pub fn header(&self, name: &str) -> Option<&HeaderValue>
Return a header value
Will return None
if the header does not exist.
Sourcepub fn set_header(&mut self, name: impl Into<String>, value: impl Into<String>)
pub fn set_header(&mut self, name: impl Into<String>, value: impl Into<String>)
Set a response header
Sourcepub fn into_builder(self) -> ResponseBuilder
pub fn into_builder(self) -> ResponseBuilder
Converts this response into a ResponseBuilder
. This can be used to
update a response before passing it on.
Sourcepub fn builder() -> ResponseBuilder
pub fn builder() -> ResponseBuilder
Creates a ResponseBuilder
Trait Implementations§
Source§impl IntoResponse for Response
impl IntoResponse for Response
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Turn
self
into a Response
Source§impl TryFrom<Response> for OutgoingResponse
impl TryFrom<Response> for OutgoingResponse
Source§impl TryFromIncomingResponse for Response
impl TryFromIncomingResponse for Response
Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnwindSafe for Response
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
Mutably borrows from an owned value. Read more