pub struct Response { /* private fields */ }
Implementations§
Source§impl Response
impl Response
pub fn new(body: ResponseBody) -> Self
pub fn new_with_status(body: ResponseBody, status: StatusCode) -> Self
pub fn html(body: String) -> Self
pub fn text(body: String) -> Self
pub fn json<T: Serialize>(body: &T) -> Result<Response, Error>
Sourcepub fn stream<T, E>(stream: T) -> Self
pub fn stream<T, E>(stream: T) -> Self
Create a response from a stream of Result<Frame<Bytes>, Error>
.
pub fn not_found() -> Self
pub fn build() -> ResponseBuilder
pub fn from_parts(parts: Parts, body: ResponseBody) -> Self
Sourcepub fn into_parts(self) -> (Parts, ResponseBody)
pub fn into_parts(self) -> (Parts, ResponseBody)
Consumes the response and returns a tuple containing the component parts of the response and the response body.
Sourcepub fn map<F, T>(self, map: F) -> Self
pub fn map<F, T>(self, map: F) -> Self
Consumes the response returning a new response with body mapped to the
return type of the provided closure map
.
pub fn body(&self) -> &ResponseBody
pub fn body_mut(&mut self) -> &mut ResponseBody
Returns a reference to the response cookies.
Returns a mutable reference to the response cookies.
pub fn headers(&self) -> &HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Sourcepub fn set_header(&mut self, name: HeaderName, value: HeaderValue)
pub fn set_header(&mut self, name: HeaderName, value: HeaderValue)
A shorthand method for self.headers_mut().insert(name, value)
.
pub fn status(&self) -> StatusCode
pub fn status_mut(&mut self) -> &mut StatusCode
Sourcepub fn set_status(&mut self, status: StatusCode)
pub fn set_status(&mut self, status: StatusCode)
A shorthand method for *self.status_mut() = status
.
pub fn version(&self) -> Version
Trait Implementations§
Source§impl From<Response<ResponseBody>> for Response
impl From<Response<ResponseBody>> for Response
Source§fn from(response: Response<ResponseBody>) -> Self
fn from(response: Response<ResponseBody>) -> Self
Converts to this type from the input type.
Source§impl IntoResponse for Response
impl IntoResponse for Response
fn into_response(self) -> Result<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