style: deny unreachable_pub lint (#1058)

This commit is contained in:
Paolo Barbolini
2025-02-23 10:17:17 +01:00
committed by GitHub
parent b4ddcbdcfc
commit f0de9ef02c
12 changed files with 30 additions and 28 deletions

View File

@@ -53,7 +53,7 @@ mod serde_forward_path {
} }
} }
} }
pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<Address>, D::Error> pub(super) fn deserialize<'de, D>(deserializer: D) -> Result<Vec<Address>, D::Error>
where where
D: serde::Deserializer<'de>, D: serde::Deserializer<'de>,
{ {

View File

@@ -45,6 +45,7 @@ use crate::transport::smtp::Error;
#[async_trait] #[async_trait]
pub trait Executor: Debug + Send + Sync + 'static + private::Sealed { pub trait Executor: Debug + Send + Sync + 'static + private::Sealed {
#[cfg(feature = "smtp-transport")] #[cfg(feature = "smtp-transport")]
#[allow(private_bounds)]
type Handle: SpawnHandle; type Handle: SpawnHandle;
#[cfg(feature = "smtp-transport")] #[cfg(feature = "smtp-transport")]
type Sleep: Future<Output = ()> + Send + 'static; type Sleep: Future<Output = ()> + Send + 'static;
@@ -82,7 +83,7 @@ pub trait Executor: Debug + Send + Sync + 'static + private::Sealed {
#[doc(hidden)] #[doc(hidden)]
#[cfg(feature = "smtp-transport")] #[cfg(feature = "smtp-transport")]
#[async_trait] #[async_trait]
pub trait SpawnHandle: Debug + Send + Sync + 'static + private::Sealed { pub(crate) trait SpawnHandle: Debug + Send + Sync + 'static + private::Sealed {
async fn shutdown(self); async fn shutdown(self);
} }

View File

@@ -163,6 +163,7 @@
#![doc(html_logo_url = "https://avatars0.githubusercontent.com/u/15113230?v=4")] #![doc(html_logo_url = "https://avatars0.githubusercontent.com/u/15113230?v=4")]
#![forbid(unsafe_code)] #![forbid(unsafe_code)]
#![deny( #![deny(
unreachable_pub,
missing_copy_implementations, missing_copy_implementations,
trivial_casts, trivial_casts,
trivial_numeric_casts, trivial_numeric_casts,

View File

@@ -41,14 +41,14 @@ fn quoted_pair() -> impl Parser<char, char, Error = Cheap<char>> {
// FWS = ([*WSP CRLF] 1*WSP) / ; Folding white space // FWS = ([*WSP CRLF] 1*WSP) / ; Folding white space
// obs-FWS // obs-FWS
pub fn fws() -> impl Parser<char, Option<char>, Error = Cheap<char>> { pub(super) fn fws() -> impl Parser<char, Option<char>, Error = Cheap<char>> {
rfc2234::wsp() rfc2234::wsp()
.or_not() .or_not()
.then_ignore(rfc2234::wsp().ignored().repeated()) .then_ignore(rfc2234::wsp().ignored().repeated())
} }
// CFWS = *([FWS] comment) (([FWS] comment) / FWS) // CFWS = *([FWS] comment) (([FWS] comment) / FWS)
pub fn cfws() -> impl Parser<char, Option<char>, Error = Cheap<char>> { pub(super) fn cfws() -> impl Parser<char, Option<char>, Error = Cheap<char>> {
// TODO: comment are not currently supported, so for now a cfws is // TODO: comment are not currently supported, so for now a cfws is
// the same as a fws. // the same as a fws.
fws() fws()
@@ -106,12 +106,12 @@ pub(super) fn atom() -> impl Parser<char, Vec<char>, Error = Cheap<char>> {
} }
// dot-atom = [CFWS] dot-atom-text [CFWS] // dot-atom = [CFWS] dot-atom-text [CFWS]
pub fn dot_atom() -> impl Parser<char, Vec<char>, Error = Cheap<char>> { pub(super) fn dot_atom() -> impl Parser<char, Vec<char>, Error = Cheap<char>> {
cfws().chain(dot_atom_text()) cfws().chain(dot_atom_text())
} }
// dot-atom-text = 1*atext *("." 1*atext) // dot-atom-text = 1*atext *("." 1*atext)
pub fn dot_atom_text() -> impl Parser<char, Vec<char>, Error = Cheap<char>> { pub(super) fn dot_atom_text() -> impl Parser<char, Vec<char>, Error = Cheap<char>> {
atext().repeated().at_least(1).chain( atext().repeated().at_least(1).chain(
just('.') just('.')
.chain(atext().repeated().at_least(1)) .chain(atext().repeated().at_least(1))
@@ -204,7 +204,7 @@ pub(crate) fn mailbox_list(
// https://datatracker.ietf.org/doc/html/rfc2822#section-3.4.1 // https://datatracker.ietf.org/doc/html/rfc2822#section-3.4.1
// addr-spec = local-part "@" domain // addr-spec = local-part "@" domain
pub fn addr_spec() -> impl Parser<char, (String, String), Error = Cheap<char>> { pub(super) fn addr_spec() -> impl Parser<char, (String, String), Error = Cheap<char>> {
local_part() local_part()
.collect() .collect()
.then_ignore(just('@')) .then_ignore(just('@'))
@@ -212,12 +212,12 @@ pub fn addr_spec() -> impl Parser<char, (String, String), Error = Cheap<char>> {
} }
// local-part = dot-atom / quoted-string / obs-local-part // local-part = dot-atom / quoted-string / obs-local-part
pub fn local_part() -> impl Parser<char, Vec<char>, Error = Cheap<char>> { pub(super) fn local_part() -> impl Parser<char, Vec<char>, Error = Cheap<char>> {
choice((dot_atom(), quoted_string(), obs_local_part())) choice((dot_atom(), quoted_string(), obs_local_part()))
} }
// domain = dot-atom / domain-literal / obs-domain // domain = dot-atom / domain-literal / obs-domain
pub fn domain() -> impl Parser<char, Vec<char>, Error = Cheap<char>> { pub(super) fn domain() -> impl Parser<char, Vec<char>, Error = Cheap<char>> {
// NOTE: omitting domain-literal since it may never be used // NOTE: omitting domain-literal since it may never be used
choice((dot_atom(), obs_domain())) choice((dot_atom(), obs_domain()))
} }
@@ -240,11 +240,11 @@ fn obs_phrase() -> impl Parser<char, Vec<char>, Error = Cheap<char>> {
// https://datatracker.ietf.org/doc/html/rfc2822#section-4.4 // https://datatracker.ietf.org/doc/html/rfc2822#section-4.4
// obs-local-part = word *("." word) // obs-local-part = word *("." word)
pub fn obs_local_part() -> impl Parser<char, Vec<char>, Error = Cheap<char>> { pub(super) fn obs_local_part() -> impl Parser<char, Vec<char>, Error = Cheap<char>> {
word().chain(just('.').chain(word()).repeated().flatten()) word().chain(just('.').chain(word()).repeated().flatten())
} }
// obs-domain = atom *("." atom) // obs-domain = atom *("." atom)
pub fn obs_domain() -> impl Parser<char, Vec<char>, Error = Cheap<char>> { pub(super) fn obs_domain() -> impl Parser<char, Vec<char>, Error = Cheap<char>> {
atom().chain(just('.').chain(atom()).repeated().flatten()) atom().chain(just('.').chain(atom()).repeated().flatten())
} }

View File

@@ -460,7 +460,7 @@ impl AsyncSmtpTransportBuilder {
} }
/// Build client /// Build client
pub struct AsyncSmtpClient<E> { pub(super) struct AsyncSmtpClient<E> {
info: SmtpInfo, info: SmtpInfo,
marker_: PhantomData<E>, marker_: PhantomData<E>,
} }
@@ -472,7 +472,7 @@ where
/// Creates a new connection directly usable to send emails /// Creates a new connection directly usable to send emails
/// ///
/// Handles encryption and authentication /// Handles encryption and authentication
pub async fn connection(&self) -> Result<AsyncSmtpConnection, Error> { pub(super) async fn connection(&self) -> Result<AsyncSmtpConnection, Error> {
let mut conn = E::connect( let mut conn = E::connect(
&self.info.server, &self.info.server,
self.info.port, self.info.port,

View File

@@ -58,7 +58,7 @@ struct ClientCodec {
impl ClientCodec { impl ClientCodec {
/// Creates a new client codec /// Creates a new client codec
pub fn new() -> Self { pub(crate) fn new() -> Self {
Self { Self {
status: CodecStatus::StartOfNewLine, status: CodecStatus::StartOfNewLine,
} }

View File

@@ -490,7 +490,7 @@ impl TlsParametersBuilder {
#[derive(Clone)] #[derive(Clone)]
#[allow(clippy::enum_variant_names)] #[allow(clippy::enum_variant_names)]
pub enum InnerTlsParameters { pub(crate) enum InnerTlsParameters {
#[cfg(feature = "native-tls")] #[cfg(feature = "native-tls")]
NativeTls(TlsConnector), NativeTls(TlsConnector),
#[cfg(feature = "rustls")] #[cfg(feature = "rustls")]

View File

@@ -17,7 +17,7 @@ use super::{
}; };
use crate::{executor::SpawnHandle, transport::smtp::async_transport::AsyncSmtpClient, Executor}; use crate::{executor::SpawnHandle, transport::smtp::async_transport::AsyncSmtpClient, Executor};
pub struct Pool<E: Executor> { pub(crate) struct Pool<E: Executor> {
config: PoolConfig, config: PoolConfig,
connections: Mutex<Vec<ParkedConnection>>, connections: Mutex<Vec<ParkedConnection>>,
client: AsyncSmtpClient<E>, client: AsyncSmtpClient<E>,
@@ -29,13 +29,13 @@ struct ParkedConnection {
since: Instant, since: Instant,
} }
pub struct PooledConnection<E: Executor> { pub(crate) struct PooledConnection<E: Executor> {
conn: Option<AsyncSmtpConnection>, conn: Option<AsyncSmtpConnection>,
pool: Arc<Pool<E>>, pool: Arc<Pool<E>>,
} }
impl<E: Executor> Pool<E> { impl<E: Executor> Pool<E> {
pub fn new(config: PoolConfig, client: AsyncSmtpClient<E>) -> Arc<Self> { pub(crate) fn new(config: PoolConfig, client: AsyncSmtpClient<E>) -> Arc<Self> {
let pool = Arc::new(Self { let pool = Arc::new(Self {
config, config,
connections: Mutex::new(Vec::new()), connections: Mutex::new(Vec::new()),
@@ -134,7 +134,7 @@ impl<E: Executor> Pool<E> {
pool pool
} }
pub async fn connection(self: &Arc<Self>) -> Result<PooledConnection<E>, Error> { pub(crate) async fn connection(self: &Arc<Self>) -> Result<PooledConnection<E>, Error> {
loop { loop {
let conn = { let conn = {
let mut connections = self.connections.lock().await; let mut connections = self.connections.lock().await;

View File

@@ -1,8 +1,8 @@
use std::time::Duration; use std::time::Duration;
#[cfg(any(feature = "tokio1", feature = "async-std1"))] #[cfg(any(feature = "tokio1", feature = "async-std1"))]
pub mod async_impl; pub(super) mod async_impl;
pub mod sync_impl; pub(super) mod sync_impl;
/// Configuration for a connection pool /// Configuration for a connection pool
#[derive(Debug, Clone)] #[derive(Debug, Clone)]

View File

@@ -13,7 +13,7 @@ use super::{
}; };
use crate::transport::smtp::transport::SmtpClient; use crate::transport::smtp::transport::SmtpClient;
pub struct Pool { pub(crate) struct Pool {
config: PoolConfig, config: PoolConfig,
connections: Mutex<Vec<ParkedConnection>>, connections: Mutex<Vec<ParkedConnection>>,
client: SmtpClient, client: SmtpClient,
@@ -24,13 +24,13 @@ struct ParkedConnection {
since: Instant, since: Instant,
} }
pub struct PooledConnection { pub(crate) struct PooledConnection {
conn: Option<SmtpConnection>, conn: Option<SmtpConnection>,
pool: Arc<Pool>, pool: Arc<Pool>,
} }
impl Pool { impl Pool {
pub fn new(config: PoolConfig, client: SmtpClient) -> Arc<Self> { pub(crate) fn new(config: PoolConfig, client: SmtpClient) -> Arc<Self> {
let pool = Arc::new(Self { let pool = Arc::new(Self {
config, config,
connections: Mutex::new(Vec::new()), connections: Mutex::new(Vec::new()),
@@ -119,7 +119,7 @@ impl Pool {
pool pool
} }
pub fn connection(self: &Arc<Self>) -> Result<PooledConnection, Error> { pub(crate) fn connection(self: &Arc<Self>) -> Result<PooledConnection, Error> {
loop { loop {
let conn = { let conn = {
let mut connections = self.connections.lock().unwrap(); let mut connections = self.connections.lock().unwrap();

View File

@@ -369,7 +369,7 @@ impl SmtpTransportBuilder {
/// Build client /// Build client
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct SmtpClient { pub(super) struct SmtpClient {
info: SmtpInfo, info: SmtpInfo,
} }
@@ -377,7 +377,7 @@ impl SmtpClient {
/// Creates a new connection directly usable to send emails /// Creates a new connection directly usable to send emails
/// ///
/// Handles encryption and authentication /// Handles encryption and authentication
pub fn connection(&self) -> Result<SmtpConnection, Error> { pub(super) fn connection(&self) -> Result<SmtpConnection, Error> {
#[allow(clippy::match_single_binding)] #[allow(clippy::match_single_binding)]
let tls_parameters = match &self.info.tls { let tls_parameters = match &self.info.tls {
#[cfg(any(feature = "native-tls", feature = "rustls", feature = "boring-tls"))] #[cfg(any(feature = "native-tls", feature = "rustls", feature = "boring-tls"))]

View File

@@ -4,7 +4,7 @@ use std::fmt::{Display, Formatter, Result as FmtResult};
/// Encode a string as xtext /// Encode a string as xtext
#[derive(Debug)] #[derive(Debug)]
pub struct XText<'a>(pub &'a str); pub(crate) struct XText<'a>(pub(crate) &'a str);
impl Display for XText<'_> { impl Display for XText<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {