Skip to content

Commit 7c0612f

Browse files
authored
rustls: Tidy std::task imports (#1367)
We use needlessly verbose references to std::task types in the `linkerd-meshtls-rustls` crate. This change simplifies these imports.
1 parent bad5e57 commit 7c0612f

File tree

2 files changed

+18
-29
lines changed

2 files changed

+18
-29
lines changed

linkerd/meshtls/rustls/src/client.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use futures::prelude::*;
22
use linkerd_io as io;
33
use linkerd_stack::{NewService, Service};
44
use linkerd_tls::{client::AlpnProtocols, ClientTls, HasNegotiatedProtocol, NegotiatedProtocolRef};
5-
use std::{pin::Pin, sync::Arc};
5+
use std::{pin::Pin, sync::Arc, task::Context};
66
use tokio::sync::watch;
77
use tokio_rustls::rustls::{ClientConfig, Session};
88

@@ -84,11 +84,8 @@ where
8484
type Error = io::Error;
8585
type Future = ConnectFuture<I>;
8686

87-
fn poll_ready(
88-
&mut self,
89-
_cx: &mut std::task::Context<'_>,
90-
) -> std::task::Poll<Result<(), Self::Error>> {
91-
std::task::Poll::Ready(Ok(()))
87+
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> io::Poll<()> {
88+
io::Poll::Ready(Ok(()))
9289
}
9390

9491
fn call(&mut self, io: I) -> Self::Future {
@@ -104,7 +101,7 @@ impl<I: io::AsyncRead + io::AsyncWrite + Unpin> io::AsyncRead for ClientIo<I> {
104101
#[inline]
105102
fn poll_read(
106103
mut self: Pin<&mut Self>,
107-
cx: &mut std::task::Context<'_>,
104+
cx: &mut Context<'_>,
108105
buf: &mut io::ReadBuf<'_>,
109106
) -> io::Poll<()> {
110107
Pin::new(&mut self.0).poll_read(cx, buf)
@@ -113,30 +110,26 @@ impl<I: io::AsyncRead + io::AsyncWrite + Unpin> io::AsyncRead for ClientIo<I> {
113110

114111
impl<I: io::AsyncRead + io::AsyncWrite + Unpin> io::AsyncWrite for ClientIo<I> {
115112
#[inline]
116-
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> io::Poll<()> {
113+
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> io::Poll<()> {
117114
Pin::new(&mut self.0).poll_flush(cx)
118115
}
119116

120117
#[inline]
121-
fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> io::Poll<()> {
118+
fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> io::Poll<()> {
122119
Pin::new(&mut self.0).poll_shutdown(cx)
123120
}
124121

125122
#[inline]
126-
fn poll_write(
127-
mut self: Pin<&mut Self>,
128-
cx: &mut std::task::Context<'_>,
129-
buf: &[u8],
130-
) -> io::Poll<usize> {
123+
fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> io::Poll<usize> {
131124
Pin::new(&mut self.0).poll_write(cx, buf)
132125
}
133126

134127
#[inline]
135128
fn poll_write_vectored(
136129
mut self: Pin<&mut Self>,
137-
cx: &mut std::task::Context<'_>,
130+
cx: &mut Context<'_>,
138131
bufs: &[io::IoSlice<'_>],
139-
) -> std::task::Poll<Result<usize, std::io::Error>> {
132+
) -> io::Poll<usize> {
140133
Pin::new(&mut self.0).poll_write_vectored(cx, bufs)
141134
}
142135

linkerd/meshtls/rustls/src/server.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use linkerd_stack::{Param, Service};
55
use linkerd_tls::{
66
ClientId, HasNegotiatedProtocol, NegotiatedProtocol, NegotiatedProtocolRef, ServerTls,
77
};
8-
use std::{pin::Pin, sync::Arc, task};
8+
use std::{pin::Pin, sync::Arc, task::Context};
99
use thiserror::Error;
1010
use tokio::sync::watch;
1111
use tokio_rustls::rustls::{Certificate, ServerConfig, Session};
@@ -99,8 +99,8 @@ where
9999
type Future = TerminateFuture<I>;
100100

101101
#[inline]
102-
fn poll_ready(&mut self, _cx: &mut task::Context<'_>) -> task::Poll<Result<(), Self::Error>> {
103-
task::Poll::Ready(Ok(()))
102+
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> io::Poll<()> {
103+
io::Poll::Ready(Ok(()))
104104
}
105105

106106
#[inline]
@@ -152,7 +152,7 @@ impl<I: io::AsyncRead + io::AsyncWrite + Unpin> io::AsyncRead for ServerIo<I> {
152152
#[inline]
153153
fn poll_read(
154154
mut self: Pin<&mut Self>,
155-
cx: &mut std::task::Context<'_>,
155+
cx: &mut Context<'_>,
156156
buf: &mut io::ReadBuf<'_>,
157157
) -> io::Poll<()> {
158158
Pin::new(&mut self.0).poll_read(cx, buf)
@@ -161,30 +161,26 @@ impl<I: io::AsyncRead + io::AsyncWrite + Unpin> io::AsyncRead for ServerIo<I> {
161161

162162
impl<I: io::AsyncRead + io::AsyncWrite + Unpin> io::AsyncWrite for ServerIo<I> {
163163
#[inline]
164-
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> io::Poll<()> {
164+
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> io::Poll<()> {
165165
Pin::new(&mut self.0).poll_flush(cx)
166166
}
167167

168168
#[inline]
169-
fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> io::Poll<()> {
169+
fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> io::Poll<()> {
170170
Pin::new(&mut self.0).poll_shutdown(cx)
171171
}
172172

173173
#[inline]
174-
fn poll_write(
175-
mut self: Pin<&mut Self>,
176-
cx: &mut std::task::Context<'_>,
177-
buf: &[u8],
178-
) -> io::Poll<usize> {
174+
fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> io::Poll<usize> {
179175
Pin::new(&mut self.0).poll_write(cx, buf)
180176
}
181177

182178
#[inline]
183179
fn poll_write_vectored(
184180
mut self: Pin<&mut Self>,
185-
cx: &mut std::task::Context<'_>,
181+
cx: &mut Context<'_>,
186182
bufs: &[io::IoSlice<'_>],
187-
) -> std::task::Poll<Result<usize, std::io::Error>> {
183+
) -> io::Poll<usize> {
188184
Pin::new(&mut self.0).poll_write_vectored(cx, bufs)
189185
}
190186

0 commit comments

Comments
 (0)