Fix: address Clippy warnings
This commit is contained in:
parent
a0f028a008
commit
5f3e7aecad
@ -73,6 +73,8 @@ use tokio_postgres::tls::{ChannelBinding, TlsConnect};
|
||||
#[cfg(test)]
|
||||
mod test;
|
||||
|
||||
type ConfigCallback = dyn Fn(&mut ConnectConfiguration, &str) -> Result<(), ErrorStack> + Sync + Send;
|
||||
|
||||
/// A `MakeTlsConnect` implementation using the `openssl` crate.
|
||||
///
|
||||
/// Requires the `runtime` Cargo feature (enabled by default).
|
||||
@ -80,7 +82,7 @@ mod test;
|
||||
#[derive(Clone)]
|
||||
pub struct MakeTlsConnector {
|
||||
connector: SslConnector,
|
||||
config: Arc<dyn Fn(&mut ConnectConfiguration, &str) -> Result<(), ErrorStack> + Sync + Send>,
|
||||
config: Arc<ConfigCallback>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime")]
|
||||
|
@ -6,7 +6,7 @@ use std::{i32, i64};
|
||||
use crate::{FromSql, IsNull, ToSql, Type};
|
||||
|
||||
/// A wrapper that can be used to represent infinity with `Type::Date` types.
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Date<T> {
|
||||
/// Represents `infinity`, a date that is later than all other dates.
|
||||
PosInfinity,
|
||||
@ -55,7 +55,7 @@ impl<T: ToSql> ToSql for Date<T> {
|
||||
|
||||
/// A wrapper that can be used to represent infinity with `Type::Timestamp` and `Type::Timestamptz`
|
||||
/// types.
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Timestamp<T> {
|
||||
/// Represents `infinity`, a timestamp that is later than all other timestamps.
|
||||
PosInfinity,
|
||||
|
@ -23,7 +23,7 @@ use std::{error, fmt, iter, mem};
|
||||
use tokio::io::{AsyncRead, AsyncWrite};
|
||||
|
||||
/// Properties required of a session.
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum TargetSessionAttrs {
|
||||
/// No special properties are required.
|
||||
@ -33,7 +33,7 @@ pub enum TargetSessionAttrs {
|
||||
}
|
||||
|
||||
/// TLS configuration.
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum SslMode {
|
||||
/// Do not use TLS.
|
||||
@ -45,7 +45,7 @@ pub enum SslMode {
|
||||
}
|
||||
|
||||
/// Channel binding configuration.
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum ChannelBinding {
|
||||
/// Do not use channel binding.
|
||||
@ -57,7 +57,7 @@ pub enum ChannelBinding {
|
||||
}
|
||||
|
||||
/// A host specification.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Host {
|
||||
/// A TCP hostname.
|
||||
Tcp(String),
|
||||
@ -144,7 +144,7 @@ pub enum Host {
|
||||
/// ```not_rust
|
||||
/// postgresql:///mydb?user=user&host=/var/lib/postgresql
|
||||
/// ```
|
||||
#[derive(PartialEq, Clone)]
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub struct Config {
|
||||
pub(crate) user: Option<String>,
|
||||
pub(crate) password: Option<Vec<u8>>,
|
||||
@ -452,7 +452,7 @@ impl Config {
|
||||
}
|
||||
}
|
||||
"target_session_attrs" => {
|
||||
let target_session_attrs = match &*value {
|
||||
let target_session_attrs = match value {
|
||||
"any" => TargetSessionAttrs::Any,
|
||||
"read-write" => TargetSessionAttrs::ReadWrite,
|
||||
_ => {
|
||||
@ -900,7 +900,7 @@ impl<'a> UrlParser<'a> {
|
||||
#[cfg(unix)]
|
||||
fn host_param(&mut self, s: &str) -> Result<(), Error> {
|
||||
let decoded = Cow::from(percent_encoding::percent_decode(s.as_bytes()));
|
||||
if decoded.get(0) == Some(&b'/') {
|
||||
if decoded.first() == Some(&b'/') {
|
||||
self.config.host_path(OsStr::from_bytes(&decoded));
|
||||
} else {
|
||||
let decoded = str::from_utf8(&decoded).map_err(|e| Error::config_parse(Box::new(e)))?;
|
||||
|
@ -28,7 +28,7 @@ where
|
||||
let port = config
|
||||
.port
|
||||
.get(i)
|
||||
.or_else(|| config.port.get(0))
|
||||
.or_else(|| config.port.first())
|
||||
.copied()
|
||||
.unwrap_or(5432);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user