Type Definition elastic::client::requests::raw::RawRequestBuilder
[−]
[src]
type RawRequestBuilder<TSender, TRequest, TBody> = RequestBuilder<TSender, RawRequestInner<TRequest, TBody>>;
A raw request builder that can be configured before sending.
Call Client.request
to get an IndexRequest
.
The send
method will either send the request synchronously or asynchronously, depending on the Client
it was created from.
Methods
impl<TSender, TRequest, TBody> RawRequestBuilder<TSender, TRequest, TBody> where
TSender: Sender,
TRequest: Into<HttpRequest<'static, TBody>>,
TBody: Into<TSender::Body>,
[src]
TSender: Sender,
TRequest: Into<HttpRequest<'static, TBody>>,
TBody: Into<TSender::Body>,
pub fn send(self) -> TSender::Response
[src]
Send a RawRequestBuilder
.
If this request is for a SyncClient
, then send
will block the current thread until a response arrives and is deserialised.
The returned SyncResponseBuilder
can be used to parse the response.
If this request is for an AsyncClient
, then send
will return a future that will resolve to the deserialised index response.
The returned AsyncResponseBuilder
can be used to parse the response.
Examples
Send a raw request synchronously and parse it to a concrete response type:
let response = client.request(SimpleSearchRequest::for_index_ty("myindex", "mytype")) .send()? .into_response::<SearchResponse<Value>>()?; // Iterate through the hits (of type `MyType`) for hit in response.hits() { println!("{:?}", hit); }
Send a raw request asynchronously and parse it to a concrete response type:
let future = client.request(SimpleSearchRequest::for_index_ty("myindex", "mytype")) .send() .and_then(|res| res.into_response::<SearchResponse<Value>>()); future.and_then(|response| { // Iterate through the hits (of type `MyType`) for hit in response.hits() { println!("{:?}", hit); } Ok(()) });