pub struct Response { /* private fields */ }Expand description
Enhanced HTTP response with rich functionality
Implementations§
Source§impl Response
impl Response
pub const fn new( status: StatusCode, version: Version, headers: HeaderMap, body: Bytes, ) -> Self
Sourcepub const fn status(&self) -> StatusCode
pub const fn status(&self) -> StatusCode
Get HTTP status code
Sourcepub const fn status_code(&self) -> u16
pub const fn status_code(&self) -> u16
Get status code as u16
Sourcepub fn json<T>(&self) -> Result<T>where
T: DeserializeOwned,
pub fn json<T>(&self) -> Result<T>where
T: DeserializeOwned,
Parse response body as JSON
Sourcepub fn json_value(&self) -> Result<Value>
pub fn json_value(&self) -> Result<Value>
Parse response body as generic JSON value
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Check if response indicates success (2xx status)
Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
Check if response indicates client error (4xx status)
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Check if response indicates server error (5xx status)
Sourcepub fn is_redirection(&self) -> bool
pub fn is_redirection(&self) -> bool
Check if response indicates redirection (3xx status)
Sourcepub fn content_length(&self) -> Option<u64>
pub fn content_length(&self) -> Option<u64>
Get content length from headers
Sourcepub fn content_type(&self) -> Option<&str>
pub fn content_type(&self) -> Option<&str>
Get content type from headers
Sourcepub fn to_legacy(&self) -> LegacyResponse
pub fn to_legacy(&self) -> LegacyResponse
Convert to legacy Response format for backward compatibility
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 UnsafeUnpin 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