Fix some lint warnings

This commit is contained in:
Ryan Leckey 2019-06-29 21:34:06 -07:00
parent 4c90e026f7
commit 735c8c366a
6 changed files with 8 additions and 16 deletions

View File

@ -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
}

View File

@ -9,7 +9,7 @@ pub enum Message {
ParameterStatus(ParameterStatus),
BackendKeyData(BackendKeyData),
ReadyForQuery(ReadyForQuery),
Response(Response),
Response(Box<Response>),
}
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)?),

View File

@ -1,4 +1,4 @@
use crate::{decode::get_str_bytes_unchecked, Decode};
use crate::Decode;
use bytes::Bytes;
use std::{io, str};

View File

@ -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);

View File

@ -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",

View File

@ -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?;
}