deprecate: having made AsyncNetworkStream public (#1059)

This commit is contained in:
Paolo Barbolini
2025-02-22 21:22:30 +01:00
committed by GitHub
parent 621853e2e3
commit 8a6f1dab0e
3 changed files with 16 additions and 1 deletions

View File

@@ -6,7 +6,8 @@ use futures_util::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
use super::async_net::AsyncTokioStream; use super::async_net::AsyncTokioStream;
#[cfg(feature = "tracing")] #[cfg(feature = "tracing")]
use super::escape_crlf; use super::escape_crlf;
use super::{AsyncNetworkStream, ClientCodec, TlsParameters}; #[allow(deprecated)]
use super::{async_net::AsyncNetworkStream, ClientCodec, TlsParameters};
use crate::{ use crate::{
transport::smtp::{ transport::smtp::{
authentication::{Credentials, Mechanism}, authentication::{Credentials, Mechanism},
@@ -35,6 +36,7 @@ macro_rules! try_smtp (
pub struct AsyncSmtpConnection { pub struct AsyncSmtpConnection {
/// TCP stream between client and server /// TCP stream between client and server
/// Value is None before connection /// Value is None before connection
#[allow(deprecated)]
stream: BufReader<AsyncNetworkStream>, stream: BufReader<AsyncNetworkStream>,
/// Panic state /// Panic state
panic: bool, panic: bool,
@@ -56,6 +58,7 @@ impl AsyncSmtpConnection {
stream: Box<dyn AsyncTokioStream>, stream: Box<dyn AsyncTokioStream>,
hello_name: &ClientId, hello_name: &ClientId,
) -> Result<AsyncSmtpConnection, Error> { ) -> Result<AsyncSmtpConnection, Error> {
#[allow(deprecated)]
let stream = AsyncNetworkStream::use_existing_tokio1(stream); let stream = AsyncNetworkStream::use_existing_tokio1(stream);
Self::connect_impl(stream, hello_name).await Self::connect_impl(stream, hello_name).await
} }
@@ -98,6 +101,7 @@ impl AsyncSmtpConnection {
tls_parameters: Option<TlsParameters>, tls_parameters: Option<TlsParameters>,
local_address: Option<IpAddr>, local_address: Option<IpAddr>,
) -> Result<AsyncSmtpConnection, Error> { ) -> Result<AsyncSmtpConnection, Error> {
#[allow(deprecated)]
let stream = let stream =
AsyncNetworkStream::connect_tokio1(server, timeout, tls_parameters, local_address) AsyncNetworkStream::connect_tokio1(server, timeout, tls_parameters, local_address)
.await?; .await?;
@@ -114,10 +118,12 @@ impl AsyncSmtpConnection {
hello_name: &ClientId, hello_name: &ClientId,
tls_parameters: Option<TlsParameters>, tls_parameters: Option<TlsParameters>,
) -> Result<AsyncSmtpConnection, Error> { ) -> Result<AsyncSmtpConnection, Error> {
#[allow(deprecated)]
let stream = AsyncNetworkStream::connect_asyncstd1(server, timeout, tls_parameters).await?; let stream = AsyncNetworkStream::connect_asyncstd1(server, timeout, tls_parameters).await?;
Self::connect_impl(stream, hello_name).await Self::connect_impl(stream, hello_name).await
} }
#[allow(deprecated)]
async fn connect_impl( async fn connect_impl(
stream: AsyncNetworkStream, stream: AsyncNetworkStream,
hello_name: &ClientId, hello_name: &ClientId,
@@ -245,6 +251,7 @@ impl AsyncSmtpConnection {
} }
/// Sets the underlying stream /// Sets the underlying stream
#[allow(deprecated)]
pub fn set_stream(&mut self, stream: AsyncNetworkStream) { pub fn set_stream(&mut self, stream: AsyncNetworkStream) {
self.stream = BufReader::new(stream); self.stream = BufReader::new(stream);
} }

View File

@@ -44,6 +44,10 @@ use crate::transport::smtp::{error, Error};
/// A network stream /// A network stream
#[derive(Debug)] #[derive(Debug)]
#[deprecated(
since = "0.11.14",
note = "This struct was not meant to be made public"
)]
pub struct AsyncNetworkStream { pub struct AsyncNetworkStream {
inner: InnerAsyncNetworkStream, inner: InnerAsyncNetworkStream,
} }
@@ -89,6 +93,7 @@ enum InnerAsyncNetworkStream {
None, None,
} }
#[allow(deprecated)]
impl AsyncNetworkStream { impl AsyncNetworkStream {
fn new(inner: InnerAsyncNetworkStream) -> Self { fn new(inner: InnerAsyncNetworkStream) -> Self {
if let InnerAsyncNetworkStream::None = inner { if let InnerAsyncNetworkStream::None = inner {
@@ -543,6 +548,7 @@ impl AsyncNetworkStream {
} }
} }
#[allow(deprecated)]
impl FuturesAsyncRead for AsyncNetworkStream { impl FuturesAsyncRead for AsyncNetworkStream {
fn poll_read( fn poll_read(
mut self: Pin<&mut Self>, mut self: Pin<&mut Self>,
@@ -598,6 +604,7 @@ impl FuturesAsyncRead for AsyncNetworkStream {
} }
} }
#[allow(deprecated)]
impl FuturesAsyncWrite for AsyncNetworkStream { impl FuturesAsyncWrite for AsyncNetworkStream {
fn poll_write( fn poll_write(
mut self: Pin<&mut Self>, mut self: Pin<&mut Self>,

View File

@@ -28,6 +28,7 @@ use std::fmt::Debug;
#[cfg(any(feature = "tokio1", feature = "async-std1"))] #[cfg(any(feature = "tokio1", feature = "async-std1"))]
pub use self::async_connection::AsyncSmtpConnection; pub use self::async_connection::AsyncSmtpConnection;
#[cfg(any(feature = "tokio1", feature = "async-std1"))] #[cfg(any(feature = "tokio1", feature = "async-std1"))]
#[allow(deprecated)]
pub use self::async_net::AsyncNetworkStream; pub use self::async_net::AsyncNetworkStream;
#[cfg(feature = "tokio1")] #[cfg(feature = "tokio1")]
pub use self::async_net::AsyncTokioStream; pub use self::async_net::AsyncTokioStream;