From 83ba93944d38304e222fda470ba7efdec6893d03 Mon Sep 17 00:00:00 2001 From: Paolo Barbolini Date: Thu, 1 May 2025 18:16:40 +0200 Subject: [PATCH] docs: add missing `doc(cfg(...))` attributes (#1085) --- src/address/envelope.rs | 1 + src/transport/file/error.rs | 1 + src/transport/file/mod.rs | 4 ++++ src/transport/smtp/client/async_connection.rs | 9 +++++++++ src/transport/smtp/client/async_net.rs | 5 +++++ src/transport/smtp/client/connection.rs | 6 ++++++ src/transport/smtp/client/net.rs | 6 ++++++ src/transport/smtp/client/tls.rs | 4 ++++ 8 files changed, 36 insertions(+) diff --git a/src/address/envelope.rs b/src/address/envelope.rs index e875798..5e263bd 100644 --- a/src/address/envelope.rs +++ b/src/address/envelope.rs @@ -163,6 +163,7 @@ impl Envelope { } #[cfg(feature = "builder")] +#[cfg_attr(docsrs, doc(cfg(feature = "builder")))] impl TryFrom<&Headers> for Envelope { type Error = Error; diff --git a/src/transport/file/error.rs b/src/transport/file/error.rs index 7e0f6e8..6799054 100644 --- a/src/transport/file/error.rs +++ b/src/transport/file/error.rs @@ -34,6 +34,7 @@ impl Error { /// Returns true if the error is an envelope serialization or deserialization error #[cfg(feature = "file-transport-envelope")] + #[cfg_attr(docsrs, doc(cfg(feature = "file-transport-envelope")))] pub fn is_envelope(&self) -> bool { matches!(self.inner.kind, Kind::Envelope) } diff --git a/src/transport/file/mod.rs b/src/transport/file/mod.rs index 5ec0605..b4bd11b 100644 --- a/src/transport/file/mod.rs +++ b/src/transport/file/mod.rs @@ -199,6 +199,7 @@ impl FileTransport { /// Writes the email content in eml format and the envelope /// in json format. #[cfg(feature = "file-transport-envelope")] + #[cfg_attr(docsrs, doc(cfg(feature = "file-transport-envelope")))] pub fn with_envelope>(path: P) -> FileTransport { FileTransport { path: PathBuf::from(path.as_ref()), @@ -211,6 +212,7 @@ impl FileTransport { /// /// Reads the envelope and the raw message content. #[cfg(feature = "file-transport-envelope")] + #[cfg_attr(docsrs, doc(cfg(feature = "file-transport-envelope")))] pub fn read(&self, email_id: &str) -> Result<(Envelope, Vec), Error> { use std::fs; @@ -249,6 +251,7 @@ where /// Writes the email content in eml format and the envelope /// in json format. #[cfg(feature = "file-transport-envelope")] + #[cfg_attr(docsrs, doc(cfg(feature = "file-transport-envelope")))] pub fn with_envelope>(path: P) -> Self { Self { inner: FileTransport::with_envelope(path), @@ -260,6 +263,7 @@ where /// /// Reads the envelope and the raw message content. #[cfg(feature = "file-transport-envelope")] + #[cfg_attr(docsrs, doc(cfg(feature = "file-transport-envelope")))] pub async fn read(&self, email_id: &str) -> Result<(Envelope, Vec), Error> { let eml_file = self.inner.path.join(format!("{email_id}.eml")); let eml = E::fs_read(&eml_file).await.map_err(error::io)?; diff --git a/src/transport/smtp/client/async_connection.rs b/src/transport/smtp/client/async_connection.rs index 3149d6f..b1a2e41 100644 --- a/src/transport/smtp/client/async_connection.rs +++ b/src/transport/smtp/client/async_connection.rs @@ -54,6 +54,7 @@ impl AsyncSmtpConnection { /// /// Sends EHLO and parses server information #[cfg(feature = "tokio1")] + #[cfg_attr(docsrs, doc(cfg(feature = "tokio1")))] pub async fn connect_with_transport( stream: Box, hello_name: &ClientId, @@ -94,6 +95,7 @@ impl AsyncSmtpConnection { /// # } /// ``` #[cfg(feature = "tokio1")] + #[cfg_attr(docsrs, doc(cfg(feature = "tokio1")))] pub async fn connect_tokio1( server: T, timeout: Option, @@ -112,6 +114,7 @@ impl AsyncSmtpConnection { /// /// Sends EHLO and parses server information #[cfg(feature = "async-std1")] + #[cfg_attr(docsrs, doc(cfg(feature = "async-std1")))] pub async fn connect_asyncstd1( server: T, timeout: Option, @@ -376,6 +379,10 @@ impl AsyncSmtpConnection { /// The X509 certificate of the server (DER encoded) #[cfg(any(feature = "native-tls", feature = "rustls", feature = "boring-tls"))] + #[cfg_attr( + docsrs, + doc(cfg(any(feature = "native-tls", feature = "rustls", feature = "boring-tls"))) + )] pub fn peer_certificate(&self) -> Result, Error> { self.stream.get_ref().peer_certificate() } @@ -392,12 +399,14 @@ impl AsyncSmtpConnection { /// as the TLSA records match the leaf or issuer certificates. /// It cannot be called on non Boring TLS streams. #[cfg(feature = "boring-tls")] + #[cfg_attr(docsrs, doc(cfg(feature = "boring-tls")))] pub fn tls_verify_result(&self) -> Result<(), Error> { self.stream.get_ref().tls_verify_result() } /// All the X509 certificates of the chain (DER encoded) #[cfg(any(feature = "rustls", feature = "boring-tls"))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "rustls", feature = "boring-tls"))))] pub fn certificate_chain(&self) -> Result>, Error> { self.stream.get_ref().certificate_chain() } diff --git a/src/transport/smtp/client/async_net.rs b/src/transport/smtp/client/async_net.rs index 5b2dcfe..2679d9d 100644 --- a/src/transport/smtp/client/async_net.rs +++ b/src/transport/smtp/client/async_net.rs @@ -130,11 +130,13 @@ impl AsyncNetworkStream { } #[cfg(feature = "tokio1")] + #[cfg_attr(docsrs, doc(cfg(feature = "tokio1")))] pub fn use_existing_tokio1(stream: Box) -> AsyncNetworkStream { AsyncNetworkStream::new(InnerAsyncNetworkStream::Tokio1Tcp(stream)) } #[cfg(feature = "tokio1")] + #[cfg_attr(docsrs, doc(cfg(feature = "tokio1")))] pub async fn connect_tokio1( server: T, timeout: Option, @@ -201,6 +203,7 @@ impl AsyncNetworkStream { } #[cfg(feature = "async-std1")] + #[cfg_attr(docsrs, doc(cfg(feature = "async-std1")))] pub async fn connect_asyncstd1( server: T, timeout: Option, @@ -437,6 +440,7 @@ impl AsyncNetworkStream { } #[cfg(feature = "boring-tls")] + #[cfg_attr(docsrs, doc(cfg(feature = "boring-tls")))] pub fn tls_verify_result(&self) -> Result<(), Error> { match &self.inner { #[cfg(feature = "tokio1")] @@ -460,6 +464,7 @@ impl AsyncNetworkStream { InnerAsyncNetworkStream::None => panic!("InnerNetworkStream::None must never be built"), } } + pub fn certificate_chain(&self) -> Result>, Error> { match &self.inner { #[cfg(feature = "tokio1")] diff --git a/src/transport/smtp/client/connection.rs b/src/transport/smtp/client/connection.rs index 659d51d..1ff068b 100644 --- a/src/transport/smtp/client/connection.rs +++ b/src/transport/smtp/client/connection.rs @@ -300,6 +300,10 @@ impl SmtpConnection { /// The X509 certificate of the server (DER encoded) #[cfg(any(feature = "native-tls", feature = "rustls", feature = "boring-tls"))] + #[cfg_attr( + docsrs, + doc(cfg(any(feature = "native-tls", feature = "rustls", feature = "boring-tls"))) + )] pub fn peer_certificate(&self) -> Result, Error> { self.stream.get_ref().peer_certificate() } @@ -316,12 +320,14 @@ impl SmtpConnection { /// as the TLSA records match the leaf or issuer certificates. /// It cannot be called on non Boring TLS streams. #[cfg(feature = "boring-tls")] + #[cfg_attr(docsrs, doc(cfg(feature = "boring-tls")))] pub fn tls_verify_result(&self) -> Result<(), Error> { self.stream.get_ref().tls_verify_result() } /// All the X509 certificates of the chain (DER encoded) #[cfg(any(feature = "rustls", feature = "boring-tls"))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "rustls", feature = "boring-tls"))))] pub fn certificate_chain(&self) -> Result>, Error> { self.stream.get_ref().certificate_chain() } diff --git a/src/transport/smtp/client/net.rs b/src/transport/smtp/client/net.rs index dc7397f..5d3c963 100644 --- a/src/transport/smtp/client/net.rs +++ b/src/transport/smtp/client/net.rs @@ -222,6 +222,7 @@ impl NetworkStream { } #[cfg(feature = "boring-tls")] + #[cfg_attr(docsrs, doc(cfg(feature = "boring-tls")))] pub fn tls_verify_result(&self) -> Result<(), Error> { match &self.inner { InnerNetworkStream::Tcp(_) => Err(error::client("Connection is not encrypted")), @@ -238,6 +239,7 @@ impl NetworkStream { } #[cfg(any(feature = "rustls", feature = "boring-tls"))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "rustls", feature = "boring-tls"))))] pub fn certificate_chain(&self) -> Result>, Error> { match &self.inner { InnerNetworkStream::Tcp(_) => Err(error::client("Connection is not encrypted")), @@ -264,6 +266,10 @@ impl NetworkStream { } #[cfg(any(feature = "native-tls", feature = "rustls", feature = "boring-tls"))] + #[cfg_attr( + docsrs, + doc(cfg(any(feature = "native-tls", feature = "rustls", feature = "boring-tls"))) + )] pub fn peer_certificate(&self) -> Result, Error> { match &self.inner { InnerNetworkStream::Tcp(_) => Err(error::client("Connection is not encrypted")), diff --git a/src/transport/smtp/client/tls.rs b/src/transport/smtp/client/tls.rs index 15791eb..2dfa9f4 100644 --- a/src/transport/smtp/client/tls.rs +++ b/src/transport/smtp/client/tls.rs @@ -242,6 +242,10 @@ impl TlsParametersBuilder { /// /// Defaults to [`Tlsv12`][TlsVersion::Tlsv12]. #[cfg(any(feature = "native-tls", feature = "rustls", feature = "boring-tls"))] + #[cfg_attr( + docsrs, + doc(cfg(any(feature = "native-tls", feature = "rustls", feature = "boring-tls"))) + )] pub fn set_min_tls_version(mut self, min_tls_version: TlsVersion) -> Self { self.min_tls_version = min_tls_version; self