pub struct Response {
pub status: StatusCode,
pub headers: Headers,
pub body: Option<Body>,
pub extensions: TypeMap<TypeMapInner>,
}
Expand description
The response representation given to Middleware
Fields§
§status: StatusCode
The response status-code.
headers: Headers
The headers of the response.
body: Option<Body>
The body of the response.
extensions: TypeMap<TypeMapInner>
A TypeMap to be used as an extensible storage for data associated with this Response.
Implementations§
Source§impl Response
impl Response
Sourcepub fn new_redirect<R: Into<Raw>>(location: R) -> Response
pub fn new_redirect<R: Into<Raw>>(location: R) -> Response
Construct a redirect Response
Sourcepub fn with_status(self, status: StatusCode) -> Self
pub fn with_status(self, status: StatusCode) -> Self
Set the status and move the Response.
Useful for the “builder-style” pattern.
Sourcepub fn with_header<H: Header>(self, header: H) -> Self
pub fn with_header<H: Header>(self, header: H) -> Self
Set a header and move the Response.
Useful for the “builder-style” pattern.
Sourcepub fn with_headers(self, headers: Headers) -> Self
pub fn with_headers(self, headers: Headers) -> Self
Set the headers and move the Response.
Useful for the “builder-style” pattern.
Sourcepub fn with_body<T: Into<Body>>(self, body: T) -> Self
pub fn with_body<T: Into<Body>>(self, body: T) -> Self
Set the body and move the Response.
Useful for the “builder-style” pattern.
Sourcepub fn with_content<C: Into<Content>>(self, content: C, mime: Mime) -> Self
pub fn with_content<C: Into<Content>>(self, content: C, mime: Mime) -> Self
Set the content and move the Response.
Useful for the “builder-style” pattern.
Sourcepub fn set_content<C: Into<Content>>(&mut self, content: C, mime: Mime)
pub fn set_content<C: Into<Content>>(&mut self, content: C, mime: Mime)
Set the content.
Trait Implementations§
Source§impl Extensible<dyn UnsafeAny + Send + Sync> for Response
impl Extensible<dyn UnsafeAny + Send + Sync> for Response
Source§fn extensions(&self) -> &TypeMap<TypeMapInner>
fn extensions(&self) -> &TypeMap<TypeMapInner>
Get a reference to the type’s extension storage.
Source§fn extensions_mut(&mut self) -> &mut TypeMap<TypeMapInner>
fn extensions_mut(&mut self) -> &mut TypeMap<TypeMapInner>
Get a mutable reference to the type’s extension storage.
Source§impl From<Response> for Response
impl From<Response> for Response
Source§fn from(from_response: HyperResponse) -> Response
fn from(from_response: HyperResponse) -> Response
Converts to this type from the input type.
Source§impl From<Response> for HyperResponse
impl From<Response> for HyperResponse
Source§fn from(from_response: Response) -> HyperResponse
fn from(from_response: Response) -> HyperResponse
Converts to this type from the input type.
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