Skip to content

Commit

Permalink
Merge pull request #28 from KodrAus/chore/serde-1.0
Browse files Browse the repository at this point in the history
Upgrade to serde 1.0
  • Loading branch information
KodrAus authored May 3, 2017
2 parents 2b12892 + 8ae4376 commit dc55ca6
Show file tree
Hide file tree
Showing 16 changed files with 547 additions and 314 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Stephan Buys <stephan.buys@panoptix.co.za>"]
name = "elastic_responses"
version = "0.6.1"
version = "0.7.0"
license = "MIT/Apache-2.0"
description = "Parses search results from Elasticsearch and presents results using convenient iterators."
documentation = "https://docs.rs/elastic_responses"
Expand All @@ -10,9 +10,9 @@ exclude = [ "samples" ]

[dependencies]
log = "~0.3"
serde = "~0.9"
serde_derive = "~0.9"
serde_json = "~0.9"
serde = "~1"
serde_derive = "~1"
serde_json = "~1"
slog = "~1.4"
slog-envlogger = "~0.5"
slog-stdlog = "~1.1"
Expand Down
11 changes: 7 additions & 4 deletions samples/bulk/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern crate elastic_responses;

use elastic_reqwest::ElasticClient;
use elastic_reqwest::req::BulkRequest;
use elastic_responses::BulkResponse;
use elastic_responses::{HttpResponse, BulkErrorsResponse};

fn get_req() -> String {
let mut bulk = String::new();
Expand All @@ -30,11 +30,14 @@ fn main() {

let (client, params) = elastic_reqwest::default().unwrap();

// Send the bulk request.
let mut res = client.elastic_req(&params, BulkRequest::new(get_req())).unwrap();
// Send the request and read the response.
let http_res = {
let res = client.elastic_req(&params, BulkRequest::new(get_req())).unwrap();
HttpResponse::from_read(res.status().to_u16(), res)
};

//Parse body to JSON. You could also use `BulkErrorsResponse`.
let body_as_json: BulkResponse = res.json().unwrap();
let body_as_json: BulkErrorsResponse = http_res.into_response().unwrap();

println!("{:?}", body_as_json);
}
9 changes: 6 additions & 3 deletions samples/search/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern crate elastic_responses;

use elastic_reqwest::{ElasticClient};
use elastic_reqwest::req::SearchRequest;
use elastic_responses::SearchResponse;
use elastic_responses::{HttpResponse, SearchResponse};

fn main() {

Expand Down Expand Up @@ -67,10 +67,13 @@ fn main() {
});

// Send the request and read the response.
let mut res = client.elastic_req(&params, SearchRequest::for_index("_all", body)).unwrap();
let http_res = {
let res = client.elastic_req(&params, SearchRequest::for_index("_all", body)).unwrap();
HttpResponse::from_read(res.status().to_u16(), res)
};

//Parse body to JSON
let body_as_json: SearchResponse = res.json().unwrap();
let body_as_json: SearchResponse = http_res.into_response().unwrap();

//Use hits() or aggs() iterators
//Hits
Expand Down
Loading

0 comments on commit dc55ca6

Please sign in to comment.