pub struct RawResult { /* private fields */ }
Expand description
Represents the raw response data from an HTTP request.
This struct provides complete access to the HTTP response including status code, content type, and body data. It supports both text and binary response bodies.
§Example
use clawspec_core::{ApiClient, RawBody};
use http::StatusCode;
let mut client = ApiClient::builder().build()?;
let raw_result = client
.get("/api/data")?
.await?
.as_raw()
.await?;
println!("Status: {}", raw_result.status_code());
if let Some(content_type) = raw_result.content_type() {
println!("Content-Type: {}", content_type);
}
match raw_result.body() {
RawBody::Text(text) => println!("Text body: {}", text),
RawBody::Binary(bytes) => println!("Binary body: {} bytes", bytes.len()),
RawBody::Empty => println!("Empty body"),
}
Implementations§
Source§impl RawResult
impl RawResult
Sourcepub fn status_code(&self) -> StatusCode
pub fn status_code(&self) -> StatusCode
Returns the HTTP status code of the response.
Sourcepub fn content_type(&self) -> Option<&ContentType>
pub fn content_type(&self) -> Option<&ContentType>
Returns the content type of the response, if present.
Sourcepub fn text(&self) -> Option<&str>
pub fn text(&self) -> Option<&str>
Returns the response body as text if it’s text content.
§Returns
Some(&str)
if the body contains textNone
if the body is binary or empty
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RawResult
impl RefUnwindSafe for RawResult
impl Send for RawResult
impl Sync for RawResult
impl Unpin for RawResult
impl UnwindSafe for RawResult
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