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 !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