pub struct HttpResponse {
pub status: StatusCode,
pub headers: HeaderMap,
pub body: Bytes,
}Expand description
An HTTP response containing status, headers, and body.
Fields§
§status: StatusCode§headers: HeaderMap§body: BytesImplementations§
Source§impl HttpResponse
impl HttpResponse
Sourcepub fn new(status: StatusCode) -> Self
pub fn new(status: StatusCode) -> Self
Creates a new HttpResponse with the given status code.
Sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Returns the HTTP status code.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Returns true if the status is in the 2xx range.
Sourcepub fn body_as_str(&self) -> Option<&str>
pub fn body_as_str(&self) -> Option<&str>
Returns the response body as a UTF-8 string, if valid.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for HttpResponse
impl RefUnwindSafe for HttpResponse
impl Send for HttpResponse
impl Sync for HttpResponse
impl Unpin for HttpResponse
impl UnsafeUnpin 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