From 735c8c366aa0f838e790a5367528883f7d6e8309 Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Sat, 29 Jun 2019 21:34:06 -0700 Subject: [PATCH] Fix some lint warnings --- sqlx-postgres-protocol/src/decode.rs | 8 -------- sqlx-postgres-protocol/src/message.rs | 4 ++-- sqlx-postgres-protocol/src/parameter_status.rs | 2 +- sqlx-postgres-protocol/src/password_message.rs | 2 +- sqlx-postgres-protocol/src/response.rs | 6 +++--- sqlx-postgres/src/connection/establish.rs | 2 +- 6 files changed, 8 insertions(+), 16 deletions(-) diff --git a/sqlx-postgres-protocol/src/decode.rs b/sqlx-postgres-protocol/src/decode.rs index 865fa97a..94c697b9 100644 --- a/sqlx-postgres-protocol/src/decode.rs +++ b/sqlx-postgres-protocol/src/decode.rs @@ -16,11 +16,3 @@ pub(crate) fn get_str(src: &[u8]) -> io::Result<&str> { Ok(s) } - -#[inline] -pub(crate) fn get_str_bytes_unchecked(src: &Bytes) -> Bytes { - let end = memchr(b'\0', &src).unwrap(); - let buf = src.slice_to(end); - - buf -} diff --git a/sqlx-postgres-protocol/src/message.rs b/sqlx-postgres-protocol/src/message.rs index 83b0d5f8..b2e55659 100644 --- a/sqlx-postgres-protocol/src/message.rs +++ b/sqlx-postgres-protocol/src/message.rs @@ -9,7 +9,7 @@ pub enum Message { ParameterStatus(ParameterStatus), BackendKeyData(BackendKeyData), ReadyForQuery(ReadyForQuery), - Response(Response), + Response(Box), } impl Message { @@ -41,7 +41,7 @@ impl Message { let src = src.split_to(len + 1).freeze().slice_from(5); Ok(Some(match token { - b'N' | b'E' => Message::Response(Response::decode(src)?), + b'N' | b'E' => Message::Response(Box::new(Response::decode(src)?)), b'S' => Message::ParameterStatus(ParameterStatus::decode(src)?), b'Z' => Message::ReadyForQuery(ReadyForQuery::decode(src)?), b'R' => Message::Authentication(Authentication::decode(src)?), diff --git a/sqlx-postgres-protocol/src/parameter_status.rs b/sqlx-postgres-protocol/src/parameter_status.rs index 973401e4..129d947c 100644 --- a/sqlx-postgres-protocol/src/parameter_status.rs +++ b/sqlx-postgres-protocol/src/parameter_status.rs @@ -1,4 +1,4 @@ -use crate::{decode::get_str_bytes_unchecked, Decode}; +use crate::Decode; use bytes::Bytes; use std::{io, str}; diff --git a/sqlx-postgres-protocol/src/password_message.rs b/sqlx-postgres-protocol/src/password_message.rs index ade079f7..fbac09eb 100644 --- a/sqlx-postgres-protocol/src/password_message.rs +++ b/sqlx-postgres-protocol/src/password_message.rs @@ -17,7 +17,7 @@ impl PasswordMessage { } /// Create a `PasswordMessage` by hasing the password, user, and salt together using MD5. - pub fn md5(password: &str, user: &str, salt: &[u8; 4]) -> Self { + pub fn md5(password: &str, user: &str, salt: [u8; 4]) -> Self { let mut hasher = Md5::new(); hasher.input(password); diff --git a/sqlx-postgres-protocol/src/response.rs b/sqlx-postgres-protocol/src/response.rs index 3a9280dc..d9125802 100644 --- a/sqlx-postgres-protocol/src/response.rs +++ b/sqlx-postgres-protocol/src/response.rs @@ -22,14 +22,14 @@ pub enum Severity { } impl Severity { - pub fn is_error(&self) -> bool { + pub fn is_error(self) -> bool { match self { Severity::Panic | Severity::Fatal | Severity::Error => true, _ => false, } } - pub fn is_notice(&self) -> bool { + pub fn is_notice(self) -> bool { match self { Severity::Warning | Severity::Notice @@ -41,7 +41,7 @@ impl Severity { } } - pub fn to_str(&self) -> &'static str { + pub fn to_str(self) -> &'static str { match self { Severity::Panic => "PANIC", Severity::Fatal => "FATAL", diff --git a/sqlx-postgres/src/connection/establish.rs b/sqlx-postgres/src/connection/establish.rs index 2e9607d9..187b0df4 100644 --- a/sqlx-postgres/src/connection/establish.rs +++ b/sqlx-postgres/src/connection/establish.rs @@ -59,7 +59,7 @@ pub async fn establish<'a, 'b: 'a>( conn.send(PasswordMessage::md5( options.password.unwrap_or_default(), options.user.unwrap_or_default(), - &salt, + salt, )) .await?; }