Skip to content

Commit 52ef02b

Browse files
committed
Fix macro lints
1 parent e5e7496 commit 52ef02b

File tree

3 files changed

+54
-52
lines changed

3 files changed

+54
-52
lines changed

src/aio.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -115,34 +115,34 @@ cfg_async!(
115115
}
116116
}
117117
impl_async_methods!(Connection);
118+
);
118119

119-
cfg_async_ssl_any!(
120-
use tokio_openssl::SslStream;
121-
use openssl::ssl::{SslContext, SslMethod, Ssl};
122-
use core::pin::Pin;
123-
use crate::error::SslError;
120+
cfg_async_ssl_any!(
121+
use tokio_openssl::SslStream;
122+
use openssl::ssl::{SslContext, SslMethod, Ssl};
123+
use core::pin::Pin;
124+
use crate::error::SslError;
124125

125-
/// An asynchronous database connection over Skyhash/TLS
126-
pub struct TlsConnection {
127-
stream: SslStream<TcpStream>,
128-
buffer: BytesMut
129-
}
126+
/// An asynchronous database connection over Skyhash/TLS
127+
pub struct TlsConnection {
128+
stream: SslStream<TcpStream>,
129+
buffer: BytesMut
130+
}
130131

131-
impl TlsConnection {
132-
/// Pass the `host` and `port` and the path to the CA certificate to use for TLS
133-
pub async fn new(host: &str, port: u16, sslcert: &str) -> Result<Self, SslError> {
134-
let mut ctx = SslContext::builder(SslMethod::tls_client())?;
135-
ctx.set_ca_file(sslcert)?;
136-
let ssl = Ssl::new(&ctx.build())?;
137-
let stream = TcpStream::connect((host, port)).await?;
138-
let mut stream = SslStream::new(ssl, stream)?;
139-
Pin::new(&mut stream).connect().await?;
140-
Ok(Self {
141-
stream,
142-
buffer: BytesMut::with_capacity(BUF_CAP),
143-
})
144-
}
132+
impl TlsConnection {
133+
/// Pass the `host` and `port` and the path to the CA certificate to use for TLS
134+
pub async fn new(host: &str, port: u16, sslcert: &str) -> Result<Self, SslError> {
135+
let mut ctx = SslContext::builder(SslMethod::tls_client())?;
136+
ctx.set_ca_file(sslcert)?;
137+
let ssl = Ssl::new(&ctx.build())?;
138+
let stream = TcpStream::connect((host, port)).await?;
139+
let mut stream = SslStream::new(ssl, stream)?;
140+
Pin::new(&mut stream).connect().await?;
141+
Ok(Self {
142+
stream,
143+
buffer: BytesMut::with_capacity(BUF_CAP),
144+
})
145145
}
146-
impl_async_methods!(TlsConnection);
147-
);
146+
}
147+
impl_async_methods!(TlsConnection);
148148
);

src/sync.rs

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -121,32 +121,33 @@ cfg_sync!(
121121

122122
impl_sync_methods!(Connection);
123123

124-
cfg_sync_ssl_any!(
125-
use openssl::ssl::{Ssl, SslContext, SslMethod, SslStream};
126-
use crate::error::SslError;
127-
#[derive(Debug)]
128-
/// A database connection over Skyhash/TLS
129-
pub struct TlsConnection {
130-
stream: SslStream<TcpStream>,
131-
buffer: Vec<u8>,
132-
}
124+
);
133125

134-
impl TlsConnection {
135-
/// Pass the `host` and `port` and the path to the CA certificate to use for TLS
136-
pub fn new(host: &str, port: u16, ssl_certificate: &str) -> Result<Self, SslError> {
137-
let mut ctx = SslContext::builder(SslMethod::tls_client())?;
138-
ctx.set_ca_file(ssl_certificate)?;
139-
let ssl = Ssl::new(&ctx.build())?;
140-
let stream = TcpStream::connect((host, port))?;
141-
let mut stream = SslStream::new(ssl, stream).map_err(|e| SslError::SslError(e.into()))?;
142-
stream.connect()?;
143-
Ok(Self {
144-
stream,
145-
buffer: Vec::with_capacity(BUF_CAP),
146-
})
147-
}
126+
cfg_sync_ssl_any!(
127+
use openssl::ssl::{Ssl, SslContext, SslMethod, SslStream};
128+
use crate::error::SslError;
129+
#[derive(Debug)]
130+
/// A database connection over Skyhash/TLS
131+
pub struct TlsConnection {
132+
stream: SslStream<TcpStream>,
133+
buffer: Vec<u8>,
134+
}
135+
136+
impl TlsConnection {
137+
/// Pass the `host` and `port` and the path to the CA certificate to use for TLS
138+
pub fn new(host: &str, port: u16, ssl_certificate: &str) -> Result<Self, SslError> {
139+
let mut ctx = SslContext::builder(SslMethod::tls_client())?;
140+
ctx.set_ca_file(ssl_certificate)?;
141+
let ssl = Ssl::new(&ctx.build())?;
142+
let stream = TcpStream::connect((host, port))?;
143+
let mut stream = SslStream::new(ssl, stream).map_err(|e| SslError::SslError(e.into()))?;
144+
stream.connect()?;
145+
Ok(Self {
146+
stream,
147+
buffer: Vec::with_capacity(BUF_CAP),
148+
})
148149
}
150+
}
149151

150-
impl_sync_methods!(TlsConnection);
151-
);
152+
impl_sync_methods!(TlsConnection);
152153
);

src/util.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*
1616
*/
1717

18+
#![allow(unused_macros)] // This is done just to avoid unnecessary complications
19+
1820
macro_rules! cfg_sync_ssl_any {
1921
($($body:item)*) => {
2022
$(
@@ -35,7 +37,6 @@ macro_rules! cfg_ssl_any {
3537
};
3638
}
3739

38-
3940
macro_rules! cfg_async_ssl_any {
4041
($($body:item)*) => {
4142
$(

0 commit comments

Comments
 (0)