pub struct Response {
pub status: StatusCode,
pub headers: HeaderMap,
pub body: Option<Bytes>,
pub version: Version,
}Fields§
§status: StatusCodeThe HTTP status code of the response. This is a 3-digit integer that indicates the result of the request.
headers: HeaderMapThe headers of the HTTP response. Headers are key-value pairs that provide additional information about the response.
body: Option<Bytes>The body of the HTTP response.
This is the content that is sent back to the client.
The body is represented as a Bytes object for efficient handling of binary data.
version: VersionThe HTTP version of the response.
Implementations§
Source§impl Response
impl Response
Sourcepub fn set_status(&mut self, status: u16) -> &mut Response
pub fn set_status(&mut self, status: u16) -> &mut Response
Sets the StatusCode of the response and Returns a Muteable Reference to the Response
ⓘ
res.status(200).send_text("hello");Sourcepub fn add_header(&mut self, key: &str, value: &str) -> Result<(), HeaderError>
pub fn add_header(&mut self, key: &str, value: &str) -> Result<(), HeaderError>
Adds a header to the response. The header is a key-value pair that provides additional information about the response.
Sourcepub fn send_bytes(&mut self, data: impl Into<Vec<u8>>)
pub fn send_bytes(&mut self, data: impl Into<Vec<u8>>)
Sends Given Bytes as plain text
Trait Implementations§
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