diff --git a/Cargo.toml b/Cargo.toml index 74bb1683a..989c7ec78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["crates/*"] resolver = "2" [workspace.package] -version = "0.50.5" +version = "0.51.0" authors = ["Chrislearn Young "] edition = "2021" rust-version = "1.67" @@ -81,23 +81,23 @@ rustls = "0.21.1" rustls-pemfile = "1.0" rust-embed = {version = ">= 6, <= 8"} salvo-utils = { version = "0.0.5", default-features = true } -salvo_macros = { version = "0.50.5", path = "crates/macros", default-features = false } -salvo_core = { version = "0.50.5", path = "crates/core", default-features = false } -salvo_extra = { version = "0.50.5", path = "crates/extra", default-features = false } -salvo-compression = { version = "0.50.5", path = "crates/compression", default-features = false } -salvo-cache = { version = "0.50.5", path = "crates/cache", default-features = false } -salvo-cors = { version = "0.50.5", path = "crates/cors", default-features = false } -salvo-csrf = { version = "0.50.5", path = "crates/csrf", default-features = false } -salvo-flash = { version = "0.50.5", path = "crates/flash", default-features = false } +salvo_macros = { version = "0.51.0", path = "crates/macros", default-features = false } +salvo_core = { version = "0.51.0", path = "crates/core", default-features = false } +salvo_extra = { version = "0.51.0", path = "crates/extra", default-features = false } +salvo-compression = { version = "0.51.0", path = "crates/compression", default-features = false } +salvo-cache = { version = "0.51.0", path = "crates/cache", default-features = false } +salvo-cors = { version = "0.51.0", path = "crates/cors", default-features = false } +salvo-csrf = { version = "0.51.0", path = "crates/csrf", default-features = false } +salvo-flash = { version = "0.51.0", path = "crates/flash", default-features = false } salvo-http3 = { version = "0.0.4", default-features = false } -salvo-jwt-auth = { version = "0.50.5", path = "crates/jwt-auth", default-features = false } -salvo-oapi = { version = "0.50.5", path = "./crates/oapi", default-features = false } -salvo-oapi-macros = { version = "0.50.5", path = "crates/oapi-macros", default-features = false } -salvo-otel = { version = "0.50.5", path = "crates/otel", default-features = false } -salvo-proxy = { version = "0.50.5", path = "crates/proxy", default-features = false } -salvo-rate-limiter = { version = "0.50.5", path = "crates/rate-limiter", default-features = false } -salvo-serve-static = { version = "0.50.5", path = "crates/serve-static", default-features = false } -salvo-session = { version = "0.50.5", path = "crates/session", default-features = false } +salvo-jwt-auth = { version = "0.51.0", path = "crates/jwt-auth", default-features = false } +salvo-oapi = { version = "0.51.0", path = "./crates/oapi", default-features = false } +salvo-oapi-macros = { version = "0.51.0", path = "crates/oapi-macros", default-features = false } +salvo-otel = { version = "0.51.0", path = "crates/otel", default-features = false } +salvo-proxy = { version = "0.51.0", path = "crates/proxy", default-features = false } +salvo-rate-limiter = { version = "0.51.0", path = "crates/rate-limiter", default-features = false } +salvo-serve-static = { version = "0.51.0", path = "crates/serve-static", default-features = false } +salvo-session = { version = "0.51.0", path = "crates/session", default-features = false } serde = "1" serde_json = "1" serde-xml-rs = "0.6" diff --git a/crates/compression/src/stream.rs b/crates/compression/src/stream.rs index 80677abd8..e567b3e04 100644 --- a/crates/compression/src/stream.rs +++ b/crates/compression/src/stream.rs @@ -1,7 +1,7 @@ //! Compress the body of a response. use std::collections::VecDeque; use std::future::Future; -use std::io::{self, Error as IoError, ErrorKind}; +use std::io::{self, Error as IoError, ErrorKind, Result as IoResult}; use std::pin::Pin; use std::task::{Context, Poll}; @@ -21,7 +21,7 @@ pub(super) struct EncodeStream { encoder: Option, body: B, eof: bool, - encoding: Option>>, + encoding: Option>>, } impl EncodeStream { @@ -37,13 +37,13 @@ impl EncodeStream { } impl EncodeStream>> { #[inline] - fn poll_chunk(&mut self, cx: &mut Context<'_>) -> Poll>> { + fn poll_chunk(&mut self, cx: &mut Context<'_>) -> Poll>> { Stream::poll_next(Pin::new(&mut self.body), cx).map_err(|e| IoError::new(ErrorKind::Other, e)) } } impl EncodeStream { #[inline] - fn poll_chunk(&mut self, cx: &mut Context<'_>) -> Poll>> { + fn poll_chunk(&mut self, cx: &mut Context<'_>) -> Poll>> { match ready!(Body::poll_frame(Pin::new(&mut self.body), cx)) { Some(Ok(frame)) => Poll::Ready(frame.into_data().map(Ok).ok()), Some(Err(e)) => Poll::Ready(Some(Err(IoError::new(ErrorKind::Other, e)))), @@ -53,7 +53,7 @@ impl EncodeStream { } impl EncodeStream> { #[inline] - fn poll_chunk(&mut self, _cx: &mut Context<'_>) -> Poll>> { + fn poll_chunk(&mut self, _cx: &mut Context<'_>) -> Poll>> { if let Some(body) = Pin::new(&mut self.body).take() { Poll::Ready(Some(Ok(body))) } else { @@ -63,7 +63,7 @@ impl EncodeStream> { } impl EncodeStream> { #[inline] - fn poll_chunk(&mut self, _cx: &mut Context<'_>) -> Poll>> { + fn poll_chunk(&mut self, _cx: &mut Context<'_>) -> Poll>> { if let Some(body) = Pin::new(&mut self.body).pop_front() { Poll::Ready(Some(Ok(body))) } else { @@ -75,7 +75,7 @@ impl EncodeStream> { macro_rules! impl_stream { ($name: ty) => { impl Stream for EncodeStream<$name> { - type Item = Result; + type Item = IoResult; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { let this = self.get_mut(); loop { diff --git a/crates/core/src/conn/acme/cache.rs b/crates/core/src/conn/acme/cache.rs index be8a9d1b1..5a33dbeac 100644 --- a/crates/core/src/conn/acme/cache.rs +++ b/crates/core/src/conn/acme/cache.rs @@ -5,7 +5,7 @@ Note that the files contain private keys. */ use std::error::Error as StdError; -use std::io::{Error as IoError, ErrorKind}; +use std::io::{Error as IoError, ErrorKind, Result as IoResult}; use std::path::Path; use async_trait::async_trait; @@ -150,7 +150,7 @@ where } } #[inline] -async fn write_data(file_path: impl AsRef + Send, data: impl AsRef<[u8]> + Send) -> Result<(), IoError> { +async fn write_data(file_path: impl AsRef + Send, data: impl AsRef<[u8]> + Send) -> IoResult<()> { let mut file = OpenOptions::new(); file.write(true).create(true).truncate(true); #[cfg(unix)] diff --git a/crates/core/src/conn/acme/listener.rs b/crates/core/src/conn/acme/listener.rs index c400917e9..abf5f7b6f 100644 --- a/crates/core/src/conn/acme/listener.rs +++ b/crates/core/src/conn/acme/listener.rs @@ -281,7 +281,7 @@ where } #[inline] - async fn accept(&mut self) -> Result, IoError> { + async fn accept(&mut self) -> IoResult> { let Accepted { conn, local_addr, diff --git a/crates/core/src/conn/native_tls/config.rs b/crates/core/src/conn/native_tls/config.rs index e0c03a332..18fa19315 100644 --- a/crates/core/src/conn/native_tls/config.rs +++ b/crates/core/src/conn/native_tls/config.rs @@ -1,12 +1,13 @@ //! native_tls module use std::fmt::{self, Formatter}; use std::fs::File; -use std::io::{Error as IoError, ErrorKind, Read}; +use std::io::{Error as IoError, ErrorKind, Result as IoResult, Read}; use std::path::{Path, PathBuf}; use futures_util::future::{ready, Ready}; use futures_util::stream::{once, Once, Stream}; -use tokio_native_tls::native_tls::Identity; + +pub use tokio_native_tls::native_tls::Identity; use crate::conn::IntoConfigStream; @@ -64,9 +65,9 @@ impl NativeTlsConfig { self } - /// Generate identity + /// Build identity #[inline] - pub fn identity(mut self) -> Result { + pub fn build_identity(mut self) -> IoResult { if self.pkcs12.is_empty() { if let Some(path) = &self.pkcs12_path { let mut file = File::open(path)?; @@ -77,6 +78,14 @@ impl NativeTlsConfig { } } +impl TryInto for NativeTlsConfig { + type Error = IoError; + + fn try_into(self) -> IoResult { + self.build_identity() + } +} + impl IntoConfigStream for NativeTlsConfig { type Stream = Once>; diff --git a/crates/core/src/conn/native_tls/listener.rs b/crates/core/src/conn/native_tls/listener.rs index ac48db0a6..b732dd0bd 100644 --- a/crates/core/src/conn/native_tls/listener.rs +++ b/crates/core/src/conn/native_tls/listener.rs @@ -3,6 +3,7 @@ use std::io::{Error as IoError, ErrorKind, Result as IoResult}; use std::sync::Arc; use std::task::{Context, Poll}; use std::time::Duration; +use std::marker::PhantomData; use futures_util::stream::BoxStream; use futures_util::task::noop_waker_ref; @@ -17,33 +18,40 @@ use crate::conn::{Accepted, Acceptor, Holding, HttpBuilder, IntoConfigStream, Li use crate::http::{HttpConnection, Version}; use crate::service::HyperHandler; -use super::NativeTlsConfig; +use super::Identity; /// NativeTlsListener -pub struct NativeTlsListener { - config_stream: C, +pub struct NativeTlsListener { + config_stream: S, inner: T, + _config: PhantomData, } -impl NativeTlsListener +impl NativeTlsListener where - C: IntoConfigStream + Send + 'static, + S: IntoConfigStream + Send + 'static, + C: TryInto + Send + 'static, T: Listener + Send, { /// Create a new `NativeTlsListener`. #[inline] - pub fn new(config_stream: C, inner: T) -> Self { - NativeTlsListener { config_stream, inner } + pub fn new(config_stream: S, inner: T) -> Self { + NativeTlsListener { + config_stream, + inner, + _config: PhantomData, + } } } #[async_trait] -impl Listener for NativeTlsListener +impl Listener for NativeTlsListener where - C: IntoConfigStream + Send + 'static, + S: IntoConfigStream + Send + 'static, + C: TryInto + Send + 'static, T: Listener + Send, T::Acceptor: Send + 'static, { - type Acceptor = NativeTlsAcceptor, T::Acceptor>; + type Acceptor = NativeTlsAcceptor, C, T::Acceptor>; async fn bind(self) -> Self::Acceptor { self.try_bind().await.unwrap() @@ -77,18 +85,19 @@ where } /// NativeTlsAcceptor -pub struct NativeTlsAcceptor { - config_stream: C, +pub struct NativeTlsAcceptor { + config_stream: S, inner: T, holdings: Vec, tls_acceptor: Option, + _config: PhantomData, } -impl NativeTlsAcceptor +impl NativeTlsAcceptor where T: Acceptor, { /// Create a new `NativeTlsAcceptor`. - pub fn new(config_stream: C, inner: T) -> NativeTlsAcceptor { + pub fn new(config_stream: S, inner: T) -> NativeTlsAcceptor { let holdings = inner .holdings() .iter() @@ -114,14 +123,16 @@ where inner, holdings, tls_acceptor: None, + _config: PhantomData, } } } #[async_trait] -impl Acceptor for NativeTlsAcceptor +impl Acceptor for NativeTlsAcceptor where - C: Stream + Send + Unpin + 'static, + S: Stream + Send + Unpin + 'static, + C: TryInto + Send + 'static, T: Acceptor + Send + 'static, ::Conn: AsyncRead + AsyncWrite + Unpin + Send, { @@ -145,7 +156,7 @@ where config }; if let Some(config) = config { - let identity = config.identity()?; + let identity = config.try_into()?; let tls_acceptor = tokio_native_tls::native_tls::TlsAcceptor::new(identity); match tls_acceptor { Ok(tls_acceptor) => { diff --git a/crates/core/src/conn/native_tls/mod.rs b/crates/core/src/conn/native_tls/mod.rs index 847b52b9f..b1a75db44 100644 --- a/crates/core/src/conn/native_tls/mod.rs +++ b/crates/core/src/conn/native_tls/mod.rs @@ -3,7 +3,7 @@ pub mod listener; pub use listener::NativeTlsListener; mod config; -pub use config::NativeTlsConfig; +pub use config::{Identity, NativeTlsConfig}; #[cfg(test)] mod tests { diff --git a/crates/core/src/conn/openssl/config.rs b/crates/core/src/conn/openssl/config.rs index e2ae1bc98..f7763b40c 100644 --- a/crates/core/src/conn/openssl/config.rs +++ b/crates/core/src/conn/openssl/config.rs @@ -7,12 +7,14 @@ use std::path::Path; use futures_util::future::{ready, Ready}; use futures_util::stream::{once, Once, Stream}; use openssl::pkey::PKey; -use openssl::ssl::{SslAcceptor, SslAcceptorBuilder, SslMethod, SslRef}; +use openssl::ssl::{SslAcceptor, SslMethod, SslRef}; use openssl::x509::X509; use tokio::io::ErrorKind; use crate::conn::IntoConfigStream; +pub use openssl::ssl::SslAcceptorBuilder; + /// Private key and certificate #[derive(Debug)] pub struct Keycert { @@ -119,7 +121,7 @@ impl OpensslConfig { } /// Create [`SslAcceptorBuilder`] - pub fn create_acceptor_builder(&mut self) -> Result { + pub fn create_acceptor_builder(&mut self) -> IoResult { let mut builder = SslAcceptor::mozilla_intermediate(SslMethod::tls())?; let mut certs = X509::stack_from_pem(self.keycert.cert()?)?; @@ -147,6 +149,14 @@ impl OpensslConfig { } } +impl TryInto for OpensslConfig { + type Error = IoError; + + fn try_into(mut self) -> IoResult { + self.create_acceptor_builder() + } +} + impl IntoConfigStream for OpensslConfig { type Stream = Once>; diff --git a/crates/core/src/conn/openssl/listener.rs b/crates/core/src/conn/openssl/listener.rs index eca379e44..886ec116f 100644 --- a/crates/core/src/conn/openssl/listener.rs +++ b/crates/core/src/conn/openssl/listener.rs @@ -1,7 +1,9 @@ //! openssl module use std::io::{Error as IoError, Result as IoResult}; +use std::marker::PhantomData; use std::sync::Arc; -use std::task::{Context, Poll};use std::time::Duration; +use std::task::{Context, Poll}; +use std::time::Duration; use futures_util::stream::BoxStream; use futures_util::task::noop_waker_ref; @@ -10,9 +12,10 @@ use http::uri::Scheme; use openssl::ssl::{Ssl, SslAcceptor}; use tokio::io::ErrorKind; use tokio::io::{AsyncRead, AsyncWrite}; -use tokio_openssl::SslStream;use tokio_util::sync::CancellationToken; +use tokio_openssl::SslStream; +use tokio_util::sync::CancellationToken; -use super::OpensslConfig; +use super::SslAcceptorBuilder; use crate::async_trait; use crate::conn::{Accepted, Acceptor, Holding, HttpBuilder, IntoConfigStream, Listener}; @@ -20,31 +23,38 @@ use crate::http::{HttpConnection, Version}; use crate::service::HyperHandler; /// OpensslListener -pub struct OpensslListener { - config_stream: C, +pub struct OpensslListener { + config_stream: S, inner: T, + _config: PhantomData, } -impl OpensslListener +impl OpensslListener where - C: IntoConfigStream + Send + 'static, + S: IntoConfigStream + Send + 'static, + C: TryInto + Send + 'static, T: Listener + Send, { /// Create new OpensslListener with config stream. #[inline] - pub fn new(config_stream: C, inner: T) -> Self { - OpensslListener { config_stream, inner } + pub fn new(config_stream: S, inner: T) -> Self { + OpensslListener { + config_stream, + inner, + _config: PhantomData, + } } } #[async_trait] -impl Listener for OpensslListener +impl Listener for OpensslListener where - C: IntoConfigStream + Send + 'static, + S: IntoConfigStream + Send + 'static, + C: TryInto + Send + 'static, T: Listener + Send, T::Acceptor: Send + 'static, { - type Acceptor = OpensslAcceptor, T::Acceptor>; + type Acceptor = OpensslAcceptor, C, T::Acceptor>; async fn bind(self) -> Self::Acceptor { self.try_bind().await.unwrap() @@ -59,18 +69,21 @@ where } /// OpensslAcceptor -pub struct OpensslAcceptor { - config_stream: C, +pub struct OpensslAcceptor { + config_stream: S, inner: T, holdings: Vec, tls_acceptor: Option>, + _config: PhantomData, } -impl OpensslAcceptor +impl OpensslAcceptor where - T: Acceptor, + S: futures_util::Stream + Send + 'static, + C: TryInto + Send + 'static, + T: Acceptor + Send, { /// Create new OpensslAcceptor. - pub fn new(config_stream: C, inner: T) -> OpensslAcceptor { + pub fn new(config_stream: S, inner: T) -> OpensslAcceptor { let holdings = inner .holdings() .iter() @@ -96,6 +109,7 @@ where inner, holdings, tls_acceptor: None, + _config: PhantomData, } } } @@ -120,9 +134,10 @@ where } #[async_trait] -impl Acceptor for OpensslAcceptor +impl Acceptor for OpensslAcceptor where - C: Stream + Send + Unpin + 'static, + S: Stream + Send + Unpin + 'static, + C: TryInto + Send + 'static, T: Acceptor + Send + 'static, { type Conn = SslStream; @@ -144,8 +159,8 @@ where } config }; - if let Some(mut config) = config { - match config.create_acceptor_builder() { + if let Some(config) = config { + match config.try_into() { Ok(builder) => { if self.tls_acceptor.is_some() { tracing::info!("tls config changed."); diff --git a/crates/core/src/conn/openssl/mod.rs b/crates/core/src/conn/openssl/mod.rs index ce4fd50be..7a43fab9d 100644 --- a/crates/core/src/conn/openssl/mod.rs +++ b/crates/core/src/conn/openssl/mod.rs @@ -1,6 +1,6 @@ //! openssl module mod config; -pub use config::{Keycert, OpensslConfig}; +pub use config::{Keycert, OpensslConfig, SslAcceptorBuilder}; mod listener; pub use listener::{OpensslAcceptor, OpensslListener}; diff --git a/crates/core/src/conn/rustls/config.rs b/crates/core/src/conn/rustls/config.rs index 042d2fdb8..5c1484861 100644 --- a/crates/core/src/conn/rustls/config.rs +++ b/crates/core/src/conn/rustls/config.rs @@ -244,6 +244,14 @@ impl RustlsConfig { } } +impl TryInto for RustlsConfig { + type Error = IoError; + + fn try_into(self) -> IoResult { + self.build_server_config() + } +} + pub(crate) struct CertResolver { fallback: Option>, certified_keys: HashMap>, diff --git a/crates/core/src/conn/rustls/listener.rs b/crates/core/src/conn/rustls/listener.rs index dce1b7b86..54180d3d4 100644 --- a/crates/core/src/conn/rustls/listener.rs +++ b/crates/core/src/conn/rustls/listener.rs @@ -1,5 +1,6 @@ //! rustls module use std::io::{Error as IoError, ErrorKind, Result as IoResult}; +use std::marker::PhantomData; use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}; @@ -16,34 +17,41 @@ use crate::conn::{Accepted, Acceptor, IntoConfigStream, Listener}; use crate::http::uri::Scheme; use crate::http::Version; -use super::RustlsConfig; +use super::ServerConfig; /// RustlsListener -pub struct RustlsListener { - config_stream: C, +pub struct RustlsListener { + config_stream: S, inner: T, + _config: PhantomData, } -impl RustlsListener +impl RustlsListener where - C: IntoConfigStream + Send + 'static, + S: IntoConfigStream + Send + 'static, + C: TryInto + Send + 'static, T: Listener + Send, { /// Create a new `RustlsListener`. #[inline] - pub fn new(config_stream: C, inner: T) -> Self { - RustlsListener { config_stream, inner } + pub fn new(config_stream: S, inner: T) -> Self { + RustlsListener { + config_stream, + inner, + _config: PhantomData, + } } } #[async_trait] -impl Listener for RustlsListener +impl Listener for RustlsListener where - C: IntoConfigStream + Send + 'static, + S: IntoConfigStream + Send + 'static, + C: TryInto + Send + 'static, T: Listener + Send, T::Acceptor: Send + 'static, { - type Acceptor = RustlsAcceptor, T::Acceptor>; + type Acceptor = RustlsAcceptor, C, T::Acceptor>; async fn bind(self) -> Self::Acceptor { self.try_bind().await.unwrap() @@ -58,23 +66,21 @@ where } /// RustlsAcceptor -pub struct RustlsAcceptor { - config_stream: C, +pub struct RustlsAcceptor { + config_stream: S, inner: T, holdings: Vec, tls_acceptor: Option, + _config: PhantomData, } -impl RustlsAcceptor +impl RustlsAcceptor where + S: futures_util::Stream + Send + 'static, + C: TryInto + Send + 'static, T: Acceptor + Send, - C: Send, { /// Create a new `RustlsAcceptor`. - pub fn new(config_stream: C, inner: T) -> RustlsAcceptor - where - C: Send, - T: Send, - { + pub fn new(config_stream: S, inner: T) -> RustlsAcceptor { let holdings = inner .holdings() .iter() @@ -100,14 +106,16 @@ where inner, holdings, tls_acceptor: None, + _config: PhantomData, } } } #[async_trait] -impl Acceptor for RustlsAcceptor +impl Acceptor for RustlsAcceptor where - C: Stream + Send + Unpin + 'static, + S: Stream + Send + Unpin + 'static, + C: TryInto + Send + 'static, T: Acceptor + Send + 'static, ::Conn: AsyncRead + AsyncWrite + Send + Unpin + 'static, { @@ -129,7 +137,7 @@ where config }; if let Some(config) = config { - let tls_acceptor = tokio_rustls::TlsAcceptor::from(Arc::new(config.build_server_config()?)); + let tls_acceptor = tokio_rustls::TlsAcceptor::from(Arc::new(config.try_into()?)); if self.tls_acceptor.is_some() { tracing::info!("tls config changed."); } else { diff --git a/crates/core/src/conn/tcp.rs b/crates/core/src/conn/tcp.rs index 6418a2d78..18a74a83a 100644 --- a/crates/core/src/conn/tcp.rs +++ b/crates/core/src/conn/tcp.rs @@ -19,13 +19,13 @@ use super::{Accepted, Acceptor, Listener}; use crate::conn::IntoConfigStream; #[cfg(feature = "rustls")] -use crate::conn::rustls::{RustlsConfig, RustlsListener}; +use crate::conn::rustls::RustlsListener; #[cfg(feature = "native-tls")] -use crate::conn::native_tls::{NativeTlsConfig, NativeTlsListener}; +use crate::conn::native_tls::NativeTlsListener; #[cfg(feature = "openssl")] -use crate::conn::openssl::{OpensslConfig, OpensslListener}; +use crate::conn::openssl::OpensslListener; #[cfg(feature = "acme")] use crate::conn::acme::AcmeListener; @@ -46,9 +46,10 @@ impl TcpListener { /// Creates a new `RustlsListener` from current `TcpListener`. #[inline] - pub fn rustls(self, config_stream: C) -> RustlsListener + pub fn rustls(self, config_stream: S) -> RustlsListener where - C: IntoConfigStream + Send + 'static, + S: IntoConfigStream + Send + 'static, + C: TryInto + Send + 'static, { RustlsListener::new(config_stream, self) } @@ -59,9 +60,10 @@ impl TcpListener { /// Creates a new `NativeTlsListener` from current `TcpListener`. #[inline] - pub fn native_tls(self, config_stream: C) -> NativeTlsListener + pub fn native_tls(self, config_stream: S) -> NativeTlsListener where - C: IntoConfigStream + Send + 'static, + S: IntoConfigStream + Send + 'static, + C: TryInto + Send + 'static, { NativeTlsListener::new(config_stream, self) } @@ -72,9 +74,10 @@ impl TcpListener { /// Creates a new `OpensslListener` from current `TcpListener`. #[inline] - pub fn openssl(self, config_stream: C) -> OpensslListener + pub fn openssl(self, config_stream: S) -> OpensslListener where - C: IntoConfigStream + Send + 'static, + S: IntoConfigStream + Send + 'static, + C: TryInto + Send + 'static, { OpensslListener::new(config_stream, self) } diff --git a/crates/core/src/fs/mod.rs b/crates/core/src/fs/mod.rs index 9ed047bcd..8556cdd52 100644 --- a/crates/core/src/fs/mod.rs +++ b/crates/core/src/fs/mod.rs @@ -4,7 +4,7 @@ pub use named_file::*; use std::cmp; use std::future::Future; -use std::io::{self, Error as IoError, ErrorKind, Read, Seek}; +use std::io::{self, Error as IoError, ErrorKind, Read, Result as IoResult, Seek}; use std::pin::Pin; use std::task::{Context, Poll}; @@ -14,7 +14,7 @@ use futures_util::stream::Stream; pub(crate) enum ChunkedState { File(Option), - Future(tokio::task::JoinHandle>), + Future(tokio::task::JoinHandle>), } /// A stream of bytes that reads a file in chunks. @@ -33,7 +33,7 @@ impl Stream for ChunkedFile where T: Read + Seek + Unpin + Send + 'static, { - type Item = Result; + type Item = IoResult; fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { if self.total_size == self.read_size { diff --git a/crates/core/src/http/body/req.rs b/crates/core/src/http/body/req.rs index 318d14d52..d448fea3e 100644 --- a/crates/core/src/http/body/req.rs +++ b/crates/core/src/http/body/req.rs @@ -1,7 +1,7 @@ //! Http body. use std::boxed::Box; use std::fmt::{self, Formatter}; -use std::io::{Error as IoError, ErrorKind}; +use std::io::{Error as IoError, ErrorKind, Result as IoResult}; use std::pin::Pin; use std::task::{Context, Poll}; @@ -82,7 +82,7 @@ impl Body for ReqBody { } } impl Stream for ReqBody { - type Item = Result; + type Item = IoResult; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { match Body::poll_frame(self, cx) { diff --git a/crates/core/src/http/body/res.rs b/crates/core/src/http/body/res.rs index dd63c53f4..8bea2758a 100644 --- a/crates/core/src/http/body/res.rs +++ b/crates/core/src/http/body/res.rs @@ -2,7 +2,7 @@ use std::boxed::Box; use std::collections::VecDeque; -use std::io::{Error as IoError, ErrorKind}; +use std::io::{Error as IoError, ErrorKind, Result as IoResult}; use std::pin::Pin; use std::task::{self, Context, Poll}; @@ -77,7 +77,7 @@ impl ResBody { } impl Stream for ResBody { - type Item = Result; + type Item = IoResult; #[inline] fn poll_next(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll> {