Skip to content

Commit 55907a8

Browse files
committed
Replace future (deprecated & archived) with anyhow
1 parent 634f310 commit 55907a8

File tree

25 files changed

+190
-278
lines changed

25 files changed

+190
-278
lines changed

Cargo.lock

Lines changed: 5 additions & 97 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

elasticsearch/Cargo.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ serde = { version = "1", features = ["derive"] }
4040
serde_json = "1"
4141
serde_with = "3"
4242

43-
44-
#tokio = { version = "1", default-features = false, features = ["macros", "net", "time", "rt-multi-thread"] }
4543
void = "1"
4644
flate2 = "1"
4745

@@ -51,16 +49,13 @@ default-features = false
5149
features = ["macros", "net", "time", "rt-multi-thread"]
5250

5351
[dev-dependencies]
52+
anyhow = "1"
5453
chrono = { version = "0.4", features = ["serde"] }
5554
clap = { version = "4", features = ["env"] }
56-
failure = "0.1"
57-
futures = "0.3"
5855
http = "1"
5956
axum = "0.8"
60-
#hyper = { version = "1", features = ["server", "http1"] }
6157
os_type = "2"
6258
regex = "1"
63-
#sysinfo = "0.31"
6459
textwrap = "0.16"
6560
xml-rs = "0.8"
6661

elasticsearch/src/http/request.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ mod tests {
200200
use serde_json::json;
201201

202202
#[test]
203-
fn serialize_into_jsonbody_writes_to_bytes() -> Result<(), failure::Error> {
203+
fn serialize_into_jsonbody_writes_to_bytes() -> anyhow::Result<()> {
204204
let mut bytes = BytesMut::new();
205205
let body: JsonBody<_> = json!({"foo":"bar","baz":1}).into();
206206
body.write(&mut bytes)?;
@@ -211,7 +211,7 @@ mod tests {
211211
}
212212

213213
#[test]
214-
fn bodies_into_ndbody_writes_to_bytes() -> Result<(), failure::Error> {
214+
fn bodies_into_ndbody_writes_to_bytes() -> anyhow::Result<()> {
215215
let mut bytes = BytesMut::new();
216216
let mut bodies: Vec<JsonBody<_>> = Vec::with_capacity(2);
217217
bodies.push(json!({"item":1}).into());
@@ -225,7 +225,7 @@ mod tests {
225225
}
226226

227227
#[test]
228-
fn boxed_bodies_into_ndbody_writes_to_bytes() -> Result<(), failure::Error> {
228+
fn boxed_bodies_into_ndbody_writes_to_bytes() -> anyhow::Result<()> {
229229
let mut bytes = BytesMut::new();
230230
let mut bodies: Vec<Box<dyn Body>> = Vec::with_capacity(2);
231231
bodies.push(Box::new(JsonBody::from(json!({"item":1}))));
@@ -239,7 +239,7 @@ mod tests {
239239
}
240240

241241
#[test]
242-
fn bytes_body_writes_to_bytes_mut() -> Result<(), failure::Error> {
242+
fn bytes_body_writes_to_bytes_mut() -> anyhow::Result<()> {
243243
let mut bytes_mut = BytesMut::with_capacity(21);
244244
let bytes = bytes::Bytes::from(&b"{\"foo\":\"bar\",\"baz\":1}"[..]);
245245
bytes.write(&mut bytes_mut)?;
@@ -249,7 +249,7 @@ mod tests {
249249
}
250250

251251
#[test]
252-
fn bytes_body_returns_usable_buf() -> Result<(), failure::Error> {
252+
fn bytes_body_returns_usable_buf() -> anyhow::Result<()> {
253253
let mut bytes_mut = BytesMut::with_capacity(21);
254254
let buf = bytes::Bytes::from(&b"{\"foo\":\"bar\",\"baz\":1}"[..]);
255255

@@ -262,7 +262,7 @@ mod tests {
262262
}
263263

264264
#[test]
265-
fn vec_body_writes_to_bytes_mut() -> Result<(), failure::Error> {
265+
fn vec_body_writes_to_bytes_mut() -> anyhow::Result<()> {
266266
let mut bytes_mut = BytesMut::with_capacity(21);
267267
let bytes = b"{\"foo\":\"bar\",\"baz\":1}".to_vec();
268268
bytes.write(&mut bytes_mut)?;
@@ -272,7 +272,7 @@ mod tests {
272272
}
273273

274274
#[test]
275-
fn bytes_slice_body_writes_to_bytes_mut() -> Result<(), failure::Error> {
275+
fn bytes_slice_body_writes_to_bytes_mut() -> anyhow::Result<()> {
276276
let mut bytes_mut = BytesMut::with_capacity(21);
277277
let bytes: &'static [u8] = b"{\"foo\":\"bar\",\"baz\":1}";
278278
bytes.write(&mut bytes_mut)?;
@@ -282,7 +282,7 @@ mod tests {
282282
}
283283

284284
#[test]
285-
fn string_body_writes_to_bytes_mut() -> Result<(), failure::Error> {
285+
fn string_body_writes_to_bytes_mut() -> anyhow::Result<()> {
286286
let mut bytes_mut = BytesMut::with_capacity(21);
287287
let s = String::from("{\"foo\":\"bar\",\"baz\":1}");
288288
s.write(&mut bytes_mut)?;
@@ -292,7 +292,7 @@ mod tests {
292292
}
293293

294294
#[test]
295-
fn string_slice_body_writes_to_bytes_mut() -> Result<(), failure::Error> {
295+
fn string_slice_body_writes_to_bytes_mut() -> anyhow::Result<()> {
296296
let mut bytes_mut = BytesMut::with_capacity(21);
297297
let s: &'static str = "{\"foo\":\"bar\",\"baz\":1}";
298298
s.write(&mut bytes_mut)?;

elasticsearch/src/http/response.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ pub mod tests {
371371
use serde_json::json;
372372

373373
#[test]
374-
fn deserialize_error_string() -> Result<(), failure::Error> {
374+
fn deserialize_error_string() -> anyhow::Result<()> {
375375
let json = r#"{"error":"no handler found for uri [/test_1/test/1/_update?_source=foo%2Cbar] and method [POST]"}"#;
376376
let ex: Exception = serde_json::from_str(json)?;
377377

@@ -383,7 +383,7 @@ pub mod tests {
383383
}
384384

385385
#[test]
386-
fn deserialize_illegal_argument_exception() -> Result<(), failure::Error> {
386+
fn deserialize_illegal_argument_exception() -> anyhow::Result<()> {
387387
let json = r#"{
388388
"error": {
389389
"root_cause": [{
@@ -477,7 +477,7 @@ pub mod tests {
477477
}
478478

479479
#[test]
480-
fn deserialize_index_not_found_exception() -> Result<(), failure::Error> {
480+
fn deserialize_index_not_found_exception() -> anyhow::Result<()> {
481481
let json = r#"{
482482
"error": {
483483
"root_cause": [{

elasticsearch/src/root/bulk.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ mod tests {
686686
}
687687

688688
#[test]
689-
fn serialize_bulk_operations_with_same_type_writes_to_bytes() -> Result<(), failure::Error> {
689+
fn serialize_bulk_operations_with_same_type_writes_to_bytes() -> anyhow::Result<()> {
690690
let mut bytes = BytesMut::new();
691691
let mut ops: Vec<BulkOperation<Value>> = Vec::with_capacity(4);
692692

@@ -760,8 +760,7 @@ mod tests {
760760
}
761761

762762
#[test]
763-
fn serialize_bulk_operations_with_different_types_writes_to_bytes() -> Result<(), failure::Error>
764-
{
763+
fn serialize_bulk_operations_with_different_types_writes_to_bytes() -> anyhow::Result<()> {
765764
#[derive(Serialize)]
766765
struct IndexDoc<'a> {
767766
foo: &'a str,

elasticsearch/tests/auth.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use base64::{engine::general_purpose::STANDARD as BASE64_STANDARD, write::Encode
2525
use std::io::Write;
2626

2727
#[tokio::test]
28-
async fn basic_auth_header() -> Result<(), failure::Error> {
28+
async fn basic_auth_header() -> anyhow::Result<()> {
2929
let server = server::http(move |req| async move {
3030
let mut header_value = b"Basic ".to_vec();
3131
{
@@ -50,7 +50,7 @@ async fn basic_auth_header() -> Result<(), failure::Error> {
5050
}
5151

5252
#[tokio::test]
53-
async fn api_key_header() -> Result<(), failure::Error> {
53+
async fn api_key_header() -> anyhow::Result<()> {
5454
let server = server::http(move |req| async move {
5555
let mut header_value = b"ApiKey ".to_vec();
5656
{
@@ -75,7 +75,7 @@ async fn api_key_header() -> Result<(), failure::Error> {
7575
}
7676

7777
#[tokio::test]
78-
async fn encoded_api_key_header() -> Result<(), failure::Error> {
78+
async fn encoded_api_key_header() -> anyhow::Result<()> {
7979
let server = server::http(move |req| async move {
8080
let mut header_value = b"ApiKey ".to_vec();
8181
{
@@ -101,7 +101,7 @@ async fn encoded_api_key_header() -> Result<(), failure::Error> {
101101
}
102102

103103
#[tokio::test]
104-
async fn bearer_header() -> Result<(), failure::Error> {
104+
async fn bearer_header() -> anyhow::Result<()> {
105105
let server = server::http(move |req| async move {
106106
assert_eq!(req.headers()["authorization"], "Bearer access_token");
107107
http::Response::default()
@@ -118,7 +118,7 @@ async fn bearer_header() -> Result<(), failure::Error> {
118118

119119
// TODO: test PKI authentication. Could configure a HttpsConnector, maybe using https://github.com/sfackler/hyper-openssl?, or send to PKI configured Elasticsearch.
120120
//#[tokio::test]
121-
//async fn client_certificate() -> Result<(), failure::Error> {
121+
//async fn client_certificate() -> anyhow::Result<()> {
122122
// let server = server::http(move |req| {
123123
// async move {
124124
// http::Response::default()

0 commit comments

Comments
 (0)