#[non_exhaustive]pub struct HttpResponse {
pub status: i32,
pub reason: String,
pub headers: Vec<HttpHeader>,
pub body: Bytes,
}Expand description
Represents an HTTP response.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.status: i32The HTTP status code, such as 200 or 404.
reason: StringThe HTTP reason phrase, such as “OK” or “Not Found”.
headers: Vec<HttpHeader>The HTTP response headers. The ordering of the headers is significant. Multiple headers with the same key may present for the response.
body: BytesThe HTTP response body. If the body is not expected, it should be empty.
Implementations§
Source§impl HttpResponse
impl HttpResponse
Sourcepub fn set_status<T: Into<i32>>(self, v: T) -> Self
pub fn set_status<T: Into<i32>>(self, v: T) -> Self
Sets the value of status.
Sourcepub fn set_reason<T: Into<String>>(self, v: T) -> Self
pub fn set_reason<T: Into<String>>(self, v: T) -> Self
Sets the value of reason.
Sourcepub fn set_headers<T, V>(self, v: T) -> Self
pub fn set_headers<T, V>(self, v: T) -> Self
Sets the value of headers.
Trait Implementations§
Source§impl Clone for HttpResponse
impl Clone for HttpResponse
Source§fn clone(&self) -> HttpResponse
fn clone(&self) -> HttpResponse
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HttpResponse
impl Debug for HttpResponse
Source§impl Default for HttpResponse
impl Default for HttpResponse
Source§fn default() -> HttpResponse
fn default() -> HttpResponse
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for HttpResponsewhere
HttpResponse: Default,
impl<'de> Deserialize<'de> for HttpResponsewhere
HttpResponse: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Message for HttpResponse
impl Message for HttpResponse
Source§impl PartialEq for HttpResponse
impl PartialEq for HttpResponse
Source§impl Serialize for HttpResponse
impl Serialize for HttpResponse
impl StructuralPartialEq for HttpResponse
Auto Trait Implementations§
impl !Freeze for HttpResponse
impl RefUnwindSafe for HttpResponse
impl Send for HttpResponse
impl Sync for HttpResponse
impl Unpin for HttpResponse
impl UnwindSafe for HttpResponse
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