diff --git a/actix-service/src/macros.rs b/actix-service/src/macros.rs index 503cf116..fc46bb9d 100644 --- a/actix-service/src/macros.rs +++ b/actix-service/src/macros.rs @@ -25,6 +25,8 @@ /// } /// } /// ``` +/// +/// [`forward_ready!`]: crate::forward_ready #[macro_export] macro_rules! always_ready { () => { diff --git a/actix-tls/Cargo.toml b/actix-tls/Cargo.toml index bbe1156c..d6b2efe2 100755 --- a/actix-tls/Cargo.toml +++ b/actix-tls/Cargo.toml @@ -48,6 +48,7 @@ actix-service = "2.0.0" actix-utils = "3.0.0" futures-core = { version = "0.3.7", default-features = false, features = ["alloc"] } +impl-more = "0.1.0" pin-project-lite = "0.2.7" tokio-util = "0.7" tracing = { version = "0.1.30", default-features = false, features = ["log"] } diff --git a/actix-tls/src/accept/native_tls.rs b/actix-tls/src/accept/native_tls.rs index b22c1ef2..f9dda144 100644 --- a/actix-tls/src/accept/native_tls.rs +++ b/actix-tls/src/accept/native_tls.rs @@ -24,7 +24,6 @@ use futures_core::future::LocalBoxFuture; use tokio_native_tls::{native_tls::Error, TlsAcceptor}; use super::{TlsError, DEFAULT_TLS_HANDSHAKE_TIMEOUT, MAX_CONN_COUNTER}; -use crate::impl_more; pub mod reexports { //! Re-exports from `native-tls` that are useful for acceptors. @@ -35,9 +34,8 @@ pub mod reexports { /// Wraps a `native-tls` based async TLS stream in order to implement [`ActixStream`]. pub struct TlsStream(tokio_native_tls::TlsStream); -impl_more::from! { tokio_native_tls::TlsStream => TlsStream } -impl_more::deref! { TlsStream => 0: tokio_native_tls::TlsStream } -impl_more::deref_mut! { TlsStream => 0 } +impl_more::impl_from!( in tokio_native_tls::TlsStream => TlsStream); +impl_more::impl_deref_and_mut!( in TlsStream => tokio_native_tls::TlsStream); impl AsyncRead for TlsStream { fn poll_read( diff --git a/actix-tls/src/accept/openssl.rs b/actix-tls/src/accept/openssl.rs index 6e65e5fc..1f068274 100644 --- a/actix-tls/src/accept/openssl.rs +++ b/actix-tls/src/accept/openssl.rs @@ -25,7 +25,6 @@ use openssl::ssl::{Error, Ssl, SslAcceptor}; use pin_project_lite::pin_project; use super::{TlsError, DEFAULT_TLS_HANDSHAKE_TIMEOUT, MAX_CONN_COUNTER}; -use crate::impl_more; pub mod reexports { //! Re-exports from `openssl` that are useful for acceptors. @@ -38,9 +37,8 @@ pub mod reexports { /// Wraps an `openssl` based async TLS stream in order to implement [`ActixStream`]. pub struct TlsStream(tokio_openssl::SslStream); -impl_more::from! { tokio_openssl::SslStream => TlsStream } -impl_more::deref! { TlsStream => 0: tokio_openssl::SslStream } -impl_more::deref_mut! { TlsStream => 0 } +impl_more::impl_from!( in tokio_openssl::SslStream => TlsStream); +impl_more::impl_deref_and_mut!( in TlsStream => tokio_openssl::SslStream); impl AsyncRead for TlsStream { fn poll_read( diff --git a/actix-tls/src/accept/rustls.rs b/actix-tls/src/accept/rustls.rs index 35fbd34a..73e77bd5 100644 --- a/actix-tls/src/accept/rustls.rs +++ b/actix-tls/src/accept/rustls.rs @@ -27,7 +27,6 @@ use tokio_rustls::rustls::ServerConfig; use tokio_rustls::{Accept, TlsAcceptor}; use super::{TlsError, DEFAULT_TLS_HANDSHAKE_TIMEOUT, MAX_CONN_COUNTER}; -use crate::impl_more; pub mod reexports { //! Re-exports from `rustls` that are useful for acceptors. @@ -38,9 +37,8 @@ pub mod reexports { /// Wraps a `rustls` based async TLS stream in order to implement [`ActixStream`]. pub struct TlsStream(tokio_rustls::server::TlsStream); -impl_more::from! { tokio_rustls::server::TlsStream => TlsStream } -impl_more::deref! { TlsStream => 0: tokio_rustls::server::TlsStream } -impl_more::deref_mut! { TlsStream => 0 } +impl_more::impl_from!( in tokio_rustls::server::TlsStream => TlsStream); +impl_more::impl_deref_and_mut!( in TlsStream => tokio_rustls::server::TlsStream); impl AsyncRead for TlsStream { fn poll_read( diff --git a/actix-tls/src/connect/connection.rs b/actix-tls/src/connect/connection.rs index 1abd4eff..3433ac1a 100644 --- a/actix-tls/src/connect/connection.rs +++ b/actix-tls/src/connect/connection.rs @@ -1,5 +1,4 @@ use super::Host; -use crate::impl_more; /// Wraps underlying I/O and the connection request that initiated it. #[derive(Debug)] @@ -8,8 +7,7 @@ pub struct Connection { pub(crate) io: IO, } -impl_more::deref! { Connection => io: IO } -impl_more::deref_mut! { Connection => io } +impl_more::impl_deref_and_mut!( in Connection => io: IO); impl Connection { /// Construct new `Connection` from request and IO parts. diff --git a/actix-tls/src/impl_more.rs b/actix-tls/src/impl_more.rs deleted file mode 100644 index c380228b..00000000 --- a/actix-tls/src/impl_more.rs +++ /dev/null @@ -1,40 +0,0 @@ -/// A helper to implement `Deref` for a type. -#[macro_export] -macro_rules! deref { - ($ty:ident $(<$($generic:ident),*>)? => $field:tt: $target:ty) => { - impl $(<$($generic),*>)? ::core::ops::Deref for $ty $(<$($generic),*>)? { - type Target = $target; - - fn deref(&self) -> &Self::Target { - &self.$field - } - } - }; -} - -/// A helper to implement `DerefMut` for a type. -#[macro_export] -macro_rules! deref_mut { - ($ty:ident $(<$($generic:ident),*>)? => $field:tt) => { - impl $(<$($generic),*>)? ::core::ops::DerefMut for $ty $(<$($generic),*>)? { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.$field - } - } - }; -} - -/// A helper to implement `From` for a unit struct. -#[macro_export] -macro_rules! from { - ($from:ty => $ty:ident $(<$($generic:ident),*>)?) => { - impl $(<$($generic),*>)? ::core::convert::From<$from> for $ty $(<$($generic),*>)? { - fn from(from: $from) -> Self { - Self(from) - } - } - }; -} - -#[allow(unused_imports)] -pub(crate) use crate::{deref, deref_mut, from}; diff --git a/actix-tls/src/lib.rs b/actix-tls/src/lib.rs index dfca00cd..39714dca 100644 --- a/actix-tls/src/lib.rs +++ b/actix-tls/src/lib.rs @@ -18,5 +18,3 @@ pub mod accept; #[cfg(feature = "connect")] #[cfg_attr(docsrs, doc(cfg(feature = "connect")))] pub mod connect; - -mod impl_more;