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]

[src]

Get the HTTP status for the response.

[src]

Get the response body from JSON.

Convert the builder into a raw HTTP response that implements Read.

[src]

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>();