Struct elastic::client::responses::SyncResponseBuilder
[−]
[src]
pub struct SyncResponseBuilder(_);
A builder for a response.
This structure wraps the completed HTTP response but gives you options for converting it into a concrete type.
You can also Read
directly from the response body.
Methods
impl SyncResponseBuilder
[src]
fn status(&self) -> u16
[src]
Get the HTTP status for the response.
fn into_raw(self) -> SyncHttpResponse
[src]
Get the response body from JSON.
Convert the builder into a raw HTTP response that implements Read
.
fn into_response<T>(self) -> Result<T> where
T: IsOk + DeserializeOwned,
[src]
T: IsOk + DeserializeOwned,
Parse an API response type from the HTTP body.
This will consume the SyncResponseBuilder
and return a concrete response type or an error.
The response is parsed according to the IsOk
implementation for T
that will inspect the response and either return an Ok(T)
or an Err(ApiError)
.
Examples
Get a strongly typed SearchResponse
:
let response = client.request(SimpleSearchRequest::for_index_ty("myindex", "mytype")) .send()? .into_response::<SearchResponse<MyType>>();
You can also read a response as a serde_json::Value
, which will be Ok(Value)
if the HTTP status code is Ok
or Err(ApiError)
otherwise:
let response = client.request(SimpleSearchRequest::for_index_ty("myindex", "mytype")) .send()? .into_response::<Value>();