pub struct Response<T> { /* private fields */ }
Expand description
Represents an HTTP response.
This struct holds the HTTP status code, headers, and body of the response. The body type is generic, allowing different types of body content.
Implementations§
source§impl<T> Response<T>
impl<T> Response<T>
sourcepub fn new(status: StatusCode, body: T) -> Self
pub fn new(status: StatusCode, body: T) -> Self
sourcepub fn with_version(status: StatusCode, version: Version, body: T) -> Self
pub fn with_version(status: StatusCode, version: Version, body: T) -> Self
Creates a new Response
with the given status code and body and version
sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Returns the status code of the response.
sourcepub fn status_mut(&mut self) -> &mut StatusCode
pub fn status_mut(&mut self) -> &mut StatusCode
Returns a mutable reference to the status code of the response.
sourcepub fn version_mut(&mut self) -> &mut Version
pub fn version_mut(&mut self) -> &mut Version
Returns a mutable reference of the http version of the response.
sourcepub fn headers_mut(&mut self) -> &mut Headers
pub fn headers_mut(&mut self) -> &mut Headers
Returns a mutable reference to the response headers.
sourcepub fn extensions(&self) -> &Extensions
pub fn extensions(&self) -> &Extensions
Returns a reference to the response body.
sourcepub fn extensions_mut(&mut self) -> &mut Extensions
pub fn extensions_mut(&mut self) -> &mut Extensions
Returns a mutable reference to the response extensions.
sourcepub fn into_parts(self) -> (StatusCode, Headers, T, Version)
pub fn into_parts(self) -> (StatusCode, Headers, T, Version)
Consumes the response and splits it into its components: the status code, headers, and body.
§Returns
A tuple containing the status code, headers, and body.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Response<T>where
T: Freeze,
impl<T> !RefUnwindSafe for Response<T>
impl<T> Send for Response<T>where
T: Send,
impl<T> Sync for Response<T>where
T: Sync,
impl<T> Unpin for Response<T>where
T: Unpin,
impl<T> !UnwindSafe for Response<T>
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