Skip to content

Commit ffa5391

Browse files
authored
chore: use standard library api (#263)
1 parent b43aeab commit ffa5391

File tree

16 files changed

+32
-75
lines changed

16 files changed

+32
-75
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ rustdoc-args = ["--cfg", "docsrs"]
2121
base64 = { version = "0.22", optional = true }
2222
bytes = "1.7.1"
2323
futures-channel = { version = "0.3", optional = true }
24-
futures-core = { version = "0.3" }
2524
futures-util = { version = "0.3.16", default-features = false, optional = true }
2625
http = "1.0"
2726
http-body = "1.0.0"

src/client/legacy/client.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
use std::error::Error as StdError;
88
use std::fmt;
9-
use std::future::Future;
9+
use std::future::{poll_fn, Future};
1010
use std::pin::Pin;
1111
use std::task::{self, Poll};
1212
use std::time::Duration;
@@ -25,7 +25,6 @@ use super::connect::HttpConnector;
2525
use super::connect::{Alpn, Connect, Connected, Connection};
2626
use super::pool::{self, Ver};
2727

28-
use crate::common::future::poll_fn;
2928
use crate::common::{lazy as hyper_lazy, timer, Exec, Lazy, SyncWrapper};
3029

3130
type BoxSendFuture = Pin<Box<dyn Future<Output = ()> + Send>>;
@@ -337,7 +336,7 @@ where
337336
e!(SendRequest, err.into_error())
338337
.with_connect_info(pooled.conn_info.clone()),
339338
))
340-
}
339+
};
341340
}
342341
};
343342

src/client/legacy/connect/dns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ pub(super) async fn resolve<R>(resolver: &mut R, name: Name) -> Result<R::Addrs,
291291
where
292292
R: Resolve,
293293
{
294-
crate::common::future::poll_fn(|cx| resolver.poll_ready(cx)).await?;
294+
std::future::poll_fn(|cx| resolver.poll_ready(cx)).await?;
295295
resolver.resolve(name).await
296296
}
297297

src/client/legacy/connect/http.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ use std::marker::PhantomData;
66
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
77
use std::pin::Pin;
88
use std::sync::Arc;
9-
use std::task::{self, Poll};
9+
use std::task::{self, ready, Poll};
1010
use std::time::Duration;
1111

12-
use futures_core::ready;
1312
use futures_util::future::Either;
1413
use http::uri::{Scheme, Uri};
1514
use pin_project_lite::pin_project;

src/client/legacy/connect/proxy/tunnel.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use std::error::Error as StdError;
22
use std::future::Future;
33
use std::marker::{PhantomData, Unpin};
44
use std::pin::Pin;
5-
use std::task::{self, Poll};
5+
use std::task::{self, ready, Poll};
66

7-
use futures_core::ready;
87
use http::{HeaderMap, HeaderValue, Uri};
98
use hyper::rt::{Read, Write};
109
use pin_project_lite::pin_project;

src/client/legacy/pool.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ use std::hash::Hash;
99
use std::ops::{Deref, DerefMut};
1010
use std::pin::Pin;
1111
use std::sync::{Arc, Mutex, Weak};
12-
use std::task::{self, Poll};
12+
use std::task::{self, ready, Poll};
1313

1414
use std::time::{Duration, Instant};
1515

1616
use futures_channel::oneshot;
17-
use futures_core::ready;
1817
use tracing::{debug, trace};
1918

2019
use hyper::rt::Timer as _;

src/client/pool/cache.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ mod internal {
2222
use std::future::Future;
2323
use std::pin::Pin;
2424
use std::sync::{Arc, Mutex, Weak};
25-
use std::task::{self, Poll};
25+
use std::task::{self, ready, Poll};
2626

27-
use futures_core::ready;
2827
use futures_util::future;
2928
use tokio::sync::oneshot;
3029
use tower_service::Service;
@@ -451,7 +450,7 @@ mod tests {
451450
let mut cache = super::builder().build(mock);
452451
handle.allow(1);
453452

454-
crate::common::future::poll_fn(|cx| cache.poll_ready(cx))
453+
std::future::poll_fn(|cx| cache.poll_ready(cx))
455454
.await
456455
.unwrap();
457456

@@ -473,7 +472,7 @@ mod tests {
473472
// only 1 connection should ever be made
474473
handle.allow(1);
475474

476-
crate::common::future::poll_fn(|cx| cache.poll_ready(cx))
475+
std::future::poll_fn(|cx| cache.poll_ready(cx))
477476
.await
478477
.unwrap();
479478
let f = cache.call(1);
@@ -485,7 +484,7 @@ mod tests {
485484
.expect("call");
486485
drop(cached);
487486

488-
crate::common::future::poll_fn(|cx| cache.poll_ready(cx))
487+
std::future::poll_fn(|cx| cache.poll_ready(cx))
489488
.await
490489
.unwrap();
491490
let f = cache.call(1);

src/client/pool/negotiate.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ mod internal {
4949
use std::future::Future;
5050
use std::pin::Pin;
5151
use std::sync::{Arc, Mutex};
52-
use std::task::{self, Poll};
52+
use std::task::{self, ready, Poll};
5353

54-
use futures_core::ready;
5554
use pin_project_lite::pin_project;
5655
use tower_layer::Layer;
5756
use tower_service::Service;
@@ -580,7 +579,7 @@ mod tests {
580579
.upgrade(layer_fn(|s| s))
581580
.build();
582581

583-
crate::common::future::poll_fn(|cx| negotiate.poll_ready(cx))
582+
std::future::poll_fn(|cx| negotiate.poll_ready(cx))
584583
.await
585584
.unwrap();
586585

@@ -605,7 +604,7 @@ mod tests {
605604
.upgrade(layer_fn(|s| s))
606605
.build();
607606

608-
crate::common::future::poll_fn(|cx| negotiate.poll_ready(cx))
607+
std::future::poll_fn(|cx| negotiate.poll_ready(cx))
609608
.await
610609
.unwrap();
611610

src/client/pool/singleton.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,8 @@ mod internal {
152152
use std::future::Future;
153153
use std::pin::Pin;
154154
use std::sync::{Mutex, Weak};
155-
use std::task::{self, Poll};
155+
use std::task::{self, ready, Poll};
156156

157-
use futures_core::ready;
158157
use pin_project_lite::pin_project;
159158
use tokio::sync::oneshot;
160159
use tower_service::Service;
@@ -351,7 +350,7 @@ mod tests {
351350
let mut singleton = Singleton::new(mock_svc);
352351

353352
handle.allow(1);
354-
crate::common::future::poll_fn(|cx| singleton.poll_ready(cx))
353+
std::future::poll_fn(|cx| singleton.poll_ready(cx))
355354
.await
356355
.unwrap();
357356
// First call: should go into Driving
@@ -374,7 +373,7 @@ mod tests {
374373
let mut singleton = Singleton::new(mock_svc);
375374

376375
handle.allow(1);
377-
crate::common::future::poll_fn(|cx| singleton.poll_ready(cx))
376+
std::future::poll_fn(|cx| singleton.poll_ready(cx))
378377
.await
379378
.unwrap();
380379
// Drive first call to completion
@@ -396,7 +395,7 @@ mod tests {
396395

397396
// Allow the singleton to be made
398397
outer_handle.allow(2);
399-
crate::common::future::poll_fn(|cx| singleton.poll_ready(cx))
398+
std::future::poll_fn(|cx| singleton.poll_ready(cx))
400399
.await
401400
.unwrap();
402401

@@ -417,15 +416,15 @@ mod tests {
417416
));
418417

419418
// Drive poll_ready on cached service
420-
let err = crate::common::future::poll_fn(|cx| cached.poll_ready(cx))
419+
let err = std::future::poll_fn(|cx| cached.poll_ready(cx))
421420
.await
422421
.err()
423422
.expect("expected poll_ready error");
424423
assert_eq!(err.to_string(), "cached poll_ready failed");
425424

426425
// After error, the singleton should be cleared, so a new call drives outer again
427426
outer_handle.allow(1);
428-
crate::common::future::poll_fn(|cx| singleton.poll_ready(cx))
427+
std::future::poll_fn(|cx| singleton.poll_ready(cx))
429428
.await
430429
.unwrap();
431430
let fut2 = singleton.call(());
@@ -436,7 +435,7 @@ mod tests {
436435

437436
// The new cached service should still work
438437
inner_handle2.allow(1);
439-
crate::common::future::poll_fn(|cx| cached2.poll_ready(cx))
438+
std::future::poll_fn(|cx| cached2.poll_ready(cx))
440439
.await
441440
.expect("expected poll_ready");
442441
let cfut2 = cached2.call(());
@@ -450,7 +449,7 @@ mod tests {
450449
let (mock_svc, mut handle) = tower_test::mock::pair::<(), &'static str>();
451450
let mut singleton = Singleton::new(mock_svc);
452451

453-
crate::common::future::poll_fn(|cx| singleton.poll_ready(cx))
452+
std::future::poll_fn(|cx| singleton.poll_ready(cx))
454453
.await
455454
.unwrap();
456455
let fut1 = singleton.call(());
@@ -469,14 +468,14 @@ mod tests {
469468
let (mock_svc, mut handle) = tower_test::mock::pair::<(), &'static str>();
470469
let mut singleton = Singleton::new(mock_svc);
471470

472-
crate::common::future::poll_fn(|cx| singleton.poll_ready(cx))
471+
std::future::poll_fn(|cx| singleton.poll_ready(cx))
473472
.await
474473
.unwrap();
475474
let mut fut1 = singleton.call(());
476475
let fut2 = singleton.call(());
477476

478477
// poll driver just once, and then drop
479-
crate::common::future::poll_fn(move |cx| {
478+
std::future::poll_fn(move |cx| {
480479
let _ = Pin::new(&mut fut1).poll(cx);
481480
Poll::Ready(())
482481
})

src/common/future.rs

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)