Skip to content

Commit

Permalink
Merge pull request #197 from elastic-rs/fix/into-raw-method
Browse files Browse the repository at this point in the history
Deprecate ResponseBuilder.raw
  • Loading branch information
KodrAus authored May 31, 2017
2 parents 8043c35 + 9ea1512 commit d946a94
Show file tree
Hide file tree
Showing 9 changed files with 30,503 additions and 2,157 deletions.
13,542 changes: 12,689 additions & 853 deletions benches/rust/elastic/flame.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8,794 changes: 7,997 additions & 797 deletions benches/rust/elastic_raw/flame.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion benches/rust/elastic_raw/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ extern crate elastic;

use std::env;
use std::io::Read;
use time::Duration;
use stopwatch::Stopwatch;

use elastic::http;
Expand Down Expand Up @@ -44,14 +45,17 @@ fn main() {
let mut sw = Stopwatch::start_new();

let req = SearchRequest::for_index_ty("bench_index", "bench_doc", BODY);
let mut res = client.request(req).send().unwrap().raw();
let mut res = client.request(req).send().unwrap().into_raw();

let mut buf = Vec::new();
res.read_to_end(&mut buf).unwrap();

sw.stop();

test::black_box(buf);

let elapsed = Duration::from_std(sw.elapsed()).unwrap();
results.push(elapsed.num_nanoseconds().unwrap());
}

results.sort();
Expand Down
4 changes: 2 additions & 2 deletions benches/rust/rs-es/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ authors = ["Ashley Mannix <[email protected]>"]
ssl = ["rs-es/ssl"]

[dependencies]
serde = "~0.9"
serde_derive = "~0.9"
serde = "~1"
serde_derive = "~1"

rs-es = { version = "*", default-features = false }

Expand Down
10,296 changes: 9,796 additions & 500 deletions benches/rust/rs-es/flame.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "elastic_derive"
version = "0.12.0"
version = "0.12.2"
authors = ["Ashley Mannix <[email protected]>"]
license = "Apache-2.0"
description = "Compile-time code generation for Elasticsearch type implementations."
Expand Down
2 changes: 1 addition & 1 deletion elastic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "elastic"
version = "0.12.0"
version = "0.12.2"
authors = ["Ashley Mannix <[email protected]>"]
license = "Apache-2.0"
keywords = ["elasticsearch", "search"]
Expand Down
2 changes: 1 addition & 1 deletion elastic/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ pub fn into_response<T>(res: ResponseBuilder) -> Result<T>

/** Try convert a `ResponseBuilder` into a raw response type. */
pub fn into_raw(res: ResponseBuilder) -> Result<HttpResponse> {
Ok(res.raw())
Ok(res.into_raw())
}

struct IntoResponse(RawResponse);
12 changes: 11 additions & 1 deletion elastic/src/client/responses/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,23 @@ impl ResponseBuilder {
Convert the builder into a raw HTTP response that implements `Read`.
*/
#[deprecated(note = "use `into_raw`")]
pub fn raw(self) -> HttpResponse {
self.into_raw()
}

/**
Get the response body from JSON.
Convert the builder into a raw HTTP response that implements `Read`.
*/
pub fn into_raw(self) -> HttpResponse {
self.0
}

/** Get a raw http response. */
fn reqwest_response(self) -> RawResponse {
self.raw().0
self.into_raw().0
}

/**
Expand Down

0 comments on commit d946a94

Please sign in to comment.