#[non_exhaustive]pub struct SendResponse {
pub status: StatusCode,
pub headers: HeaderMap,
pub body: String,
pub elapsed: Duration,
}Expand description
HTTP response from PreparedRequest::send.
Contains the full response metadata (status, headers, body text, elapsed
time). Use into_json for the common path that checks
the status code and parses JSON, or access individual fields for verbose
logging and dry-run display.
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: StatusCodeHTTP status code.
headers: HeaderMapResponse headers.
body: StringRaw response body text.
elapsed: DurationTime elapsed from request start to response body fully read.
Implementations§
Source§impl SendResponse
impl SendResponse
Sourcepub fn into_json(self) -> Result<Value, DispatchError>
pub fn into_json(self) -> Result<Value, DispatchError>
Check for a success status and parse the body as JSON.
Returns DispatchError::HttpError for non-2xx status codes.
Falls back to Value::String if the body is not valid JSON.
Sourcepub fn json(&self) -> Value
pub fn json(&self) -> Value
Parse the body as JSON without checking the status code.
Falls back to Value::String if the body is not valid JSON.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SendResponse
impl RefUnwindSafe for SendResponse
impl Send for SendResponse
impl Sync for SendResponse
impl Unpin for SendResponse
impl UnsafeUnpin for SendResponse
impl UnwindSafe for SendResponse
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