pub struct Response {
pub header: ResponseHeader,
pub body: Body,
}
Expand description
The response created from a server.
Fields§
§header: ResponseHeader
§body: Body
Implementations§
source§impl Response
impl Response
sourcepub fn new(header: ResponseHeader, body: Body) -> Response
pub fn new(header: ResponseHeader, body: Body) -> Response
Creates a new Response
.
sourcepub fn builder() -> ResponseBuilder
pub fn builder() -> ResponseBuilder
Creates a new Response
with a builder.
sourcepub fn header(&self) -> &ResponseHeader
pub fn header(&self) -> &ResponseHeader
Get the response header by reference.
sourcepub fn take_body(&mut self) -> Body
pub fn take_body(&mut self) -> Body
Takes the body replacing it with an empty one.
Note
If you used the builder to create a Response
you should probably reset the content-length
header.
pub fn text(body: impl Into<Body>) -> Response
pub fn html(body: impl Into<Body>) -> Response
Trait Implementations§
source§impl From<StatusCode> for Response
impl From<StatusCode> for Response
source§fn from(status_code: StatusCode) -> Response
fn from(status_code: StatusCode) -> Response
Converts to this type from the input type.
source§impl IntoResponse for Response
impl IntoResponse for Response
fn into_response(self) -> Response
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§
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