mirror of
https://github.com/fafhrd91/actix-net
synced 2025-06-26 19:47:43 +02:00
remove pin-project; update Unpin consrtaint
This commit is contained in:
@ -33,7 +33,6 @@ actix-server-config = "0.3.0-alpha.1"
|
||||
|
||||
log = "0.4"
|
||||
num_cpus = "1.0"
|
||||
pin-project = "0.4.5"
|
||||
mio = "0.6.19"
|
||||
net2 = "0.2"
|
||||
futures = "0.3.1"
|
||||
|
@ -6,7 +6,6 @@ use std::task::{Context, Poll};
|
||||
use actix_service::{Service, ServiceFactory};
|
||||
use futures::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
||||
use open_ssl::ssl::SslAcceptor;
|
||||
use pin_project::pin_project;
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
use tokio_openssl::{HandshakeError, SslStream};
|
||||
|
||||
@ -41,7 +40,9 @@ impl<T: AsyncRead + AsyncWrite, P> Clone for OpensslAcceptor<T, P> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: AsyncRead + AsyncWrite + Unpin + 'static, P> ServiceFactory for OpensslAcceptor<T, P> {
|
||||
impl<T: AsyncRead + AsyncWrite + Unpin + 'static, P: Unpin> ServiceFactory
|
||||
for OpensslAcceptor<T, P>
|
||||
{
|
||||
type Request = Io<T, P>;
|
||||
type Response = Io<SslStream<T>, P>;
|
||||
type Error = HandshakeError<T>;
|
||||
@ -69,7 +70,9 @@ pub struct OpensslAcceptorService<T, P> {
|
||||
io: PhantomData<(T, P)>,
|
||||
}
|
||||
|
||||
impl<T: AsyncRead + AsyncWrite + Unpin + 'static, P> Service for OpensslAcceptorService<T, P> {
|
||||
impl<T: AsyncRead + AsyncWrite + Unpin + 'static, P: Unpin> Service
|
||||
for OpensslAcceptorService<T, P>
|
||||
{
|
||||
type Request = Io<T, P>;
|
||||
type Response = Io<SslStream<T>, P>;
|
||||
type Error = HandshakeError<T>;
|
||||
@ -98,24 +101,23 @@ impl<T: AsyncRead + AsyncWrite + Unpin + 'static, P> Service for OpensslAcceptor
|
||||
}
|
||||
}
|
||||
|
||||
#[pin_project]
|
||||
pub struct OpensslAcceptorServiceFut<T, P>
|
||||
where
|
||||
P: Unpin,
|
||||
T: AsyncRead + AsyncWrite,
|
||||
{
|
||||
#[pin]
|
||||
fut: LocalBoxFuture<'static, Result<SslStream<T>, HandshakeError<T>>>,
|
||||
params: Option<P>,
|
||||
_guard: CounterGuard,
|
||||
}
|
||||
|
||||
impl<T: AsyncRead + AsyncWrite, P> Future for OpensslAcceptorServiceFut<T, P> {
|
||||
impl<T: AsyncRead + AsyncWrite, P: Unpin> Future for OpensslAcceptorServiceFut<T, P> {
|
||||
type Output = Result<Io<SslStream<T>, P>, HandshakeError<T>>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.project();
|
||||
let this = self.get_mut();
|
||||
|
||||
let io = futures::ready!(this.fut.poll(cx))?;
|
||||
let io = futures::ready!(Pin::new(&mut this.fut).poll(cx))?;
|
||||
let proto = if let Some(protos) = io.ssl().selected_alpn_protocol() {
|
||||
const H2: &[u8] = b"\x02h2";
|
||||
const HTTP10: &[u8] = b"\x08http/1.0";
|
||||
|
@ -7,7 +7,6 @@ use std::task::{Context, Poll};
|
||||
|
||||
use actix_service::{Service, ServiceFactory};
|
||||
use futures::future::{ok, Ready};
|
||||
use pin_project::pin_project;
|
||||
use rust_tls::ServerConfig;
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
use tokio_rustls::{server::TlsStream, Accept, TlsAcceptor};
|
||||
@ -43,7 +42,7 @@ impl<T, P> Clone for RustlsAcceptor<T, P> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: AsyncRead + AsyncWrite + Unpin, P> ServiceFactory for RustlsAcceptor<T, P> {
|
||||
impl<T: AsyncRead + AsyncWrite + Unpin, P: Unpin> ServiceFactory for RustlsAcceptor<T, P> {
|
||||
type Request = Io<T, P>;
|
||||
type Response = Io<TlsStream<T>, P>;
|
||||
type Error = io::Error;
|
||||
@ -72,7 +71,7 @@ pub struct RustlsAcceptorService<T, P> {
|
||||
conns: Counter,
|
||||
}
|
||||
|
||||
impl<T: AsyncRead + AsyncWrite + Unpin, P> Service for RustlsAcceptorService<T, P> {
|
||||
impl<T: AsyncRead + AsyncWrite + Unpin, P: Unpin> Service for RustlsAcceptorService<T, P> {
|
||||
type Request = Io<T, P>;
|
||||
type Response = Io<TlsStream<T>, P>;
|
||||
type Error = io::Error;
|
||||
@ -96,25 +95,24 @@ impl<T: AsyncRead + AsyncWrite + Unpin, P> Service for RustlsAcceptorService<T,
|
||||
}
|
||||
}
|
||||
|
||||
#[pin_project]
|
||||
pub struct RustlsAcceptorServiceFut<T, P>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin,
|
||||
P: Unpin,
|
||||
{
|
||||
#[pin]
|
||||
fut: Accept<T>,
|
||||
params: Option<P>,
|
||||
_guard: CounterGuard,
|
||||
}
|
||||
|
||||
impl<T: AsyncRead + AsyncWrite + Unpin, P> Future for RustlsAcceptorServiceFut<T, P> {
|
||||
impl<T: AsyncRead + AsyncWrite + Unpin, P: Unpin> Future for RustlsAcceptorServiceFut<T, P> {
|
||||
type Output = Result<Io<TlsStream<T>, P>, io::Error>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
let this = self.project();
|
||||
let this = self.get_mut();
|
||||
let params = this.params.take().unwrap();
|
||||
Poll::Ready(
|
||||
futures::ready!(this.fut.poll(cx))
|
||||
futures::ready!(Pin::new(&mut this.fut).poll(cx))
|
||||
.map(move |io| Io::from_parts(io, params, Protocol::Unknown)),
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user