Struct elasticsearch::http::response::Response
source · pub struct Response { /* private fields */ }
Expand description
A response from Elasticsearch
Implementations
sourceimpl Response
impl Response
sourcepub fn new(response: Response, method: Method) -> Self
pub fn new(response: Response, method: Method) -> Self
Creates a new instance of an Elasticsearch response
sourcepub fn content_length(&self) -> Option<u64>
pub fn content_length(&self) -> Option<u64>
Get the response content-length, if known.
Reasons it may not be known:
- The server didn’t send a
content-length
header. - The response is compressed and automatically decoded (thus changing the actual decoded length).
sourcepub fn content_type(&self) -> &str
pub fn content_type(&self) -> &str
Gets the response content-type.
sourcepub fn error_for_status_code(self) -> Result<Self, ClientError>
pub fn error_for_status_code(self) -> Result<Self, ClientError>
Turn the response into an Error if Elasticsearch returned an error.
sourcepub fn error_for_status_code_ref(&self) -> Result<&Self, ClientError>
pub fn error_for_status_code_ref(&self) -> Result<&Self, ClientError>
Turn the response into an Error if Elasticsearch returned an error.
sourcepub async fn exception(self) -> Result<Option<Exception>, ClientError>
pub async fn exception(self) -> Result<Option<Exception>, ClientError>
Asynchronously reads the response body into an Exception if Elasticsearch returned a HTTP status code in the 400-599 range.
Reading the response body consumes self
sourcepub async fn json<B>(self) -> Result<B, ClientError>where
B: DeserializeOwned,
pub async fn json<B>(self) -> Result<B, ClientError>where
B: DeserializeOwned,
Asynchronously reads the response body as JSON
Reading the response body consumes self
sourcepub fn status_code(&self) -> StatusCode
pub fn status_code(&self) -> StatusCode
Get the HTTP status code of the response
sourcepub async fn text(self) -> Result<String, ClientError>
pub async fn text(self) -> Result<String, ClientError>
Asynchronously reads the response body as plain text
Reading the response body consumes self
sourcepub async fn bytes(self) -> Result<Bytes, ClientError>
pub async fn bytes(self) -> Result<Bytes, ClientError>
Asynchronously reads the response body as bytes
Reading the response body consumes self
sourcepub fn warning_headers(&self) -> impl Iterator<Item = &str>
pub fn warning_headers(&self) -> impl Iterator<Item = &str>
Gets the Deprecation warning response headers
Deprecation headers signal the use of Elasticsearch functionality or features that are deprecated and will be removed in a future release.