Struct elastic::client::responses::ResponseBuilder [] [src]

pub struct ResponseBuilder(_);

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 ResponseBuilder
[src]

Get the HTTP status for the response.

Get the response body from JSON.

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

Parse an API response type from the HTTP body.

This will consume the ResponseBuilder 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(req)
                     .send()
                     .and_then(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(req)
                     .send()
                     .and_then(into_response::<Value>);