pub struct Response { /* private fields */ }Expand description
An HTTP response that can be sent to the client.
Implementations§
Source§impl Response
impl Response
Sourcepub fn new(status: StatusCode) -> Self
pub fn new(status: StatusCode) -> Self
Creates a new response with the given status code.
Sourcepub fn status(status: impl Into<StatusCode>) -> Self
pub fn status(status: impl Into<StatusCode>) -> Self
Creates a response with the given status code.
Sourcepub fn with_status(self, status: impl Into<StatusCode>) -> Self
pub fn with_status(self, status: impl Into<StatusCode>) -> Self
Sets the status code.
Sourcepub fn with_header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_header( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Adds a header to the response.
Sourcepub fn with_content_type(self, content_type: impl Into<String>) -> Self
pub fn with_content_type(self, content_type: impl Into<String>) -> Self
Sets the Content-Type header.
Sourcepub fn with_json<T: Serialize>(self, value: &T) -> Result<Self, Error>
pub fn with_json<T: Serialize>(self, value: &T) -> Result<Self, Error>
Sets the response body as JSON.
Sets a cookie on the response.
Sourcepub fn status_code(&self) -> StatusCode
pub fn status_code(&self) -> StatusCode
Returns the status code.
Trait Implementations§
Source§impl IntoResponse for Response
impl IntoResponse for Response
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Converts this value into a 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