pub struct Response {
pub header: ResponseHeader,
pub body: Body,
}Expand description
The response created from a server.
Fields
header: ResponseHeaderbody: BodyImplementations
sourceimpl 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 use the builder to create a Response
you should probably reset the content-length header.
sourcepub fn body_with_timeout(&mut self, timeout: Duration) -> BodyWithTimeout
pub fn body_with_timeout(&mut self, timeout: Duration) -> BodyWithTimeout
Takes the body adding a timeout to it.
Note
If you use the builder to create a Response
you should probably reset the content-length header.
Trait Implementations
sourceimpl From<StatusCode> for Response
impl From<StatusCode> for Response
sourcefn from(status_code: StatusCode) -> Response
fn from(status_code: StatusCode) -> Response
Converts to this type from the input type.
sourceimpl 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more