Skip to content

Commit 9580b35

Browse files
authoredJul 1, 2024··
feat(client): remove 'static lifetime bound on http1/2 client IO (#3667)
1 parent 3e435cf commit 9580b35

File tree

5 files changed

+16
-22
lines changed

5 files changed

+16
-22
lines changed
 

‎src/client/conn/http1.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ pub struct Parts<T> {
5151
#[must_use = "futures do nothing unless polled"]
5252
pub struct Connection<T, B>
5353
where
54-
T: Read + Write + 'static,
54+
T: Read + Write,
5555
B: Body + 'static,
5656
{
5757
inner: Dispatcher<T, B>,
5858
}
5959

6060
impl<T, B> Connection<T, B>
6161
where
62-
T: Read + Write + Unpin + 'static,
62+
T: Read + Write + Unpin,
6363
B: Body + 'static,
6464
B::Error: Into<Box<dyn StdError + Send + Sync>>,
6565
{
@@ -124,7 +124,7 @@ pub struct Builder {
124124
/// See [`client::conn`](crate::client::conn) for more.
125125
pub async fn handshake<T, B>(io: T) -> crate::Result<(SendRequest<B>, Connection<T, B>)>
126126
where
127-
T: Read + Write + Unpin + 'static,
127+
T: Read + Write + Unpin,
128128
B: Body + 'static,
129129
B::Data: Send,
130130
B::Error: Into<Box<dyn StdError + Send + Sync>>,
@@ -247,7 +247,7 @@ impl<B> fmt::Debug for SendRequest<B> {
247247

248248
impl<T, B> Connection<T, B>
249249
where
250-
T: Read + Write + Unpin + Send + 'static,
250+
T: Read + Write + Unpin + Send,
251251
B: Body + 'static,
252252
B::Error: Into<Box<dyn StdError + Send + Sync>>,
253253
{
@@ -261,7 +261,7 @@ where
261261

262262
impl<T, B> fmt::Debug for Connection<T, B>
263263
where
264-
T: Read + Write + fmt::Debug + 'static,
264+
T: Read + Write + fmt::Debug,
265265
B: Body + 'static,
266266
{
267267
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -271,7 +271,7 @@ where
271271

272272
impl<T, B> Future for Connection<T, B>
273273
where
274-
T: Read + Write + Unpin + 'static,
274+
T: Read + Write + Unpin,
275275
B: Body + 'static,
276276
B::Data: Send,
277277
B::Error: Into<Box<dyn StdError + Send + Sync>>,
@@ -509,7 +509,7 @@ impl Builder {
509509
io: T,
510510
) -> impl Future<Output = crate::Result<(SendRequest<B>, Connection<T, B>)>>
511511
where
512-
T: Read + Write + Unpin + 'static,
512+
T: Read + Write + Unpin,
513513
B: Body + 'static,
514514
B::Data: Send,
515515
B::Error: Into<Box<dyn StdError + Send + Sync>>,

‎src/client/conn/http2.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<B> Clone for SendRequest<B> {
4040
#[must_use = "futures do nothing unless polled"]
4141
pub struct Connection<T, B, E>
4242
where
43-
T: Read + Write + 'static + Unpin,
43+
T: Read + Write + Unpin,
4444
B: Body + 'static,
4545
E: Http2ClientConnExec<B, T> + Unpin,
4646
B::Error: Into<Box<dyn Error + Send + Sync>>,
@@ -70,7 +70,7 @@ pub async fn handshake<E, T, B>(
7070
io: T,
7171
) -> crate::Result<(SendRequest<B>, Connection<T, B, E>)>
7272
where
73-
T: Read + Write + Unpin + 'static,
73+
T: Read + Write + Unpin,
7474
B: Body + 'static,
7575
B::Data: Send,
7676
B::Error: Into<Box<dyn Error + Send + Sync>>,
@@ -432,7 +432,7 @@ where
432432
io: T,
433433
) -> impl Future<Output = crate::Result<(SendRequest<B>, Connection<T, B, Ex>)>>
434434
where
435-
T: Read + Write + Unpin + 'static,
435+
T: Read + Write + Unpin,
436436
B: Body + 'static,
437437
B::Data: Send,
438438
B::Error: Into<Box<dyn Error + Send + Sync>>,

‎src/proto/h1/dispatch.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ where
107107
///
108108
/// This is useful for old-style HTTP upgrades, but ignores
109109
/// newer-style upgrade API.
110-
pub(crate) fn poll_without_shutdown(&mut self, cx: &mut Context<'_>) -> Poll<crate::Result<()>>
111-
where
112-
Self: Unpin,
113-
{
110+
pub(crate) fn poll_without_shutdown(
111+
&mut self,
112+
cx: &mut Context<'_>,
113+
) -> Poll<crate::Result<()>> {
114114
Pin::new(self).poll_catch(cx, false).map_ok(|ds| {
115115
if let Dispatched::Upgrade(pending) = ds {
116116
pending.manual();

‎src/proto/h2/client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub(crate) async fn handshake<T, B, E>(
137137
timer: Time,
138138
) -> crate::Result<ClientTask<B, E, T>>
139139
where
140-
T: Read + Write + Unpin + 'static,
140+
T: Read + Write + Unpin,
141141
B: Body + 'static,
142142
B::Data: Send + 'static,
143143
E: Http2ClientConnExec<B, T> + Unpin,

‎src/server/conn/http1.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ where
166166
where
167167
S: Unpin,
168168
S::Future: Unpin,
169-
B: Unpin,
170169
{
171170
self.conn.poll_without_shutdown(cx)
172171
}
@@ -177,12 +176,7 @@ where
177176
/// # Error
178177
///
179178
/// This errors if the underlying connection protocol is not HTTP/1.
180-
pub fn without_shutdown(self) -> impl Future<Output = crate::Result<Parts<I, S>>>
181-
where
182-
S: Unpin,
183-
S::Future: Unpin,
184-
B: Unpin,
185-
{
179+
pub fn without_shutdown(self) -> impl Future<Output = crate::Result<Parts<I, S>>> {
186180
let mut zelf = Some(self);
187181
futures_util::future::poll_fn(move |cx| {
188182
ready!(zelf.as_mut().unwrap().conn.poll_without_shutdown(cx))?;

0 commit comments

Comments
 (0)
Please sign in to comment.