style: rustfmt

This commit is contained in:
Ryan Leckey 2021-04-16 11:49:47 -07:00
parent 4c0896bc14
commit 3d575495e7
12 changed files with 41 additions and 46 deletions

View File

@ -1,6 +1,7 @@
use std::ops::Not;
use crate::database::{HasOutput, HasRawValue};
use crate::{decode, encode, Database, Decode, Encode, RawValue, Type};
use std::ops::Not;
#[derive(Debug)]
pub struct Null;

View File

@ -102,11 +102,7 @@ impl Deref for CommandGuard<'_, QueryCommand> {
fn deref(&self) -> &Self::Target {
debug_assert!(!self.ended);
if let Command::Query(cmd) = &self.queue.0[self.index] {
cmd
} else {
unreachable!()
}
if let Command::Query(cmd) = &self.queue.0[self.index] { cmd } else { unreachable!() }
}
}
@ -114,11 +110,7 @@ impl DerefMut for CommandGuard<'_, QueryCommand> {
fn deref_mut(&mut self) -> &mut Self::Target {
debug_assert!(!self.ended);
if let Command::Query(cmd) = &mut self.queue.0[self.index] {
cmd
} else {
unreachable!()
}
if let Command::Query(cmd) = &mut self.queue.0[self.index] { cmd } else { unreachable!() }
}
}
@ -147,11 +139,7 @@ impl Deref for CommandGuard<'_, PrepareCommand> {
fn deref(&self) -> &Self::Target {
debug_assert!(!self.ended);
if let Command::Prepare(cmd) = &self.queue.0[self.index] {
cmd
} else {
unreachable!()
}
if let Command::Prepare(cmd) = &self.queue.0[self.index] { cmd } else { unreachable!() }
}
}
@ -159,10 +147,6 @@ impl DerefMut for CommandGuard<'_, PrepareCommand> {
fn deref_mut(&mut self) -> &mut Self::Target {
debug_assert!(!self.ended);
if let Command::Prepare(cmd) = &mut self.queue.0[self.index] {
cmd
} else {
unreachable!()
}
if let Command::Prepare(cmd) = &mut self.queue.0[self.index] { cmd } else { unreachable!() }
}
}

View File

@ -1,9 +1,10 @@
use std::error::Error as StdError;
use std::fmt::{self, Display, Formatter};
use crate::protocol::AuthPlugin;
use sqlx_core::{ClientError, Error};
use crate::protocol::AuthPlugin;
#[derive(Debug)]
#[non_exhaustive]
pub enum MySqlClientError {

View File

@ -1,12 +1,13 @@
use super::rsa::encrypt as rsa_encrypt;
use super::xor_eq;
use crate::protocol::AuthPlugin;
use crate::MySqlClientError;
use bytes::buf::Chain;
use bytes::Bytes;
use sha2::{Digest, Sha256};
use sqlx_core::Result;
use super::rsa::encrypt as rsa_encrypt;
use super::xor_eq;
use crate::protocol::AuthPlugin;
use crate::MySqlClientError;
/// Implements SHA-256 authentication but uses caching on the server-side for better performance.
/// After the first authentication, a fast path is used that doesn't involve the RSA key exchange.
///

View File

@ -1,8 +1,9 @@
use crate::MySqlClientError;
use bytes::buf::Chain;
use bytes::Bytes;
use sqlx_core::Result;
use crate::MySqlClientError;
/// Dialog authentication implementation
///
/// https://mariadb.com/kb/en/authentication-plugin-pam/#dialog

View File

@ -1,13 +1,14 @@
use std::str::from_utf8;
use crate::protocol::auth_plugin::xor_eq;
use crate::protocol::AuthPlugin;
use crate::MySqlClientError;
use bytes::buf::Chain;
use bytes::Bytes;
use rsa::{PaddingScheme, PublicKey, RSAPublicKey};
use sqlx_core::Result;
use crate::protocol::auth_plugin::xor_eq;
use crate::protocol::AuthPlugin;
use crate::MySqlClientError;
pub(crate) fn encrypt(
plugin: &impl AuthPlugin,
key: &[u8],

View File

@ -1,10 +1,11 @@
use super::rsa::encrypt as rsa_encrypt;
use crate::protocol::AuthPlugin;
use crate::MySqlClientError;
use bytes::buf::Chain;
use bytes::Bytes;
use sqlx_core::Result;
use super::rsa::encrypt as rsa_encrypt;
use crate::protocol::AuthPlugin;
use crate::MySqlClientError;
/// Implements SHA-256 authentication.
///
/// Each time we connect we have to do an RSA key exchange.

View File

@ -1,11 +1,11 @@
use std::fmt::{self, Debug, Formatter};
use sqlx_core::encode::IsNull;
use sqlx_core::io::Serialize;
use sqlx_core::{Arguments, Result};
use super::Command;
use crate::{MySql, MySqlOutput, MySqlTypeId, MySqlTypeInfo};
use sqlx_core::encode::IsNull;
// https://dev.mysql.com/doc/dev/mysql-server/8.0.12/mysql__com_8h.html#a3e5e9e744ff6f7b989a604fd669977da
const NO_CURSOR: u8 = 0;

View File

@ -1,7 +1,8 @@
use crate::{MySql, MySqlOutput, MySqlRawValue, MySqlTypeId, MySqlTypeInfo};
use sqlx_core::database::{HasOutput, HasRawValue};
use sqlx_core::{decode, encode, Database, Decode, Encode, Null, Type};
use crate::{MySql, MySqlOutput, MySqlRawValue, MySqlTypeId, MySqlTypeInfo};
impl Type<MySql> for Null {
fn type_id() -> MySqlTypeId
where

View File

@ -1,7 +1,8 @@
use sqlx_core::{DatabaseError, Error};
use std::error::Error as StdError;
use std::fmt::{self, Display, Formatter};
use sqlx_core::{DatabaseError, Error};
use crate::PgNotice;
/// An error returned from the PostgreSQL database.

View File

@ -1,14 +1,16 @@
use crate::PgClientError;
use bytes::{Buf, Bytes};
use bytestring::ByteString;
use memchr::memchr;
use sqlx_core::io::Deserialize;
use std::convert::TryFrom;
use std::fmt;
use std::fmt::{Debug, Display, Formatter};
use std::num::NonZeroU8;
use std::str::{from_utf8, FromStr};
use bytes::{Buf, Bytes};
use bytestring::ByteString;
use memchr::memchr;
use sqlx_core::io::Deserialize;
use crate::PgClientError;
#[derive(Debug, Copy, Clone, PartialEq)]
#[repr(u8)]
pub enum PgNoticeSeverity {
@ -374,7 +376,10 @@ mod tests {
assert!(notice.severity.is_error());
assert_eq!(notice.severity, PgNoticeSeverity::Fatal);
assert_eq!(notice.message, "failed to parse error received from postgres, likely invalid authentication, confirm connection information and check database logs");
assert_eq!(
notice.message,
"failed to parse error received from postgres, likely invalid authentication, confirm connection information and check database logs"
);
assert_eq!(notice.code, "28P01");
Ok(())

View File

@ -7,11 +7,9 @@ use sqlx_core::io::{BufStream, Deserialize, Serialize, Stream};
use sqlx_core::net::Stream as NetStream;
use sqlx_core::{Result, Runtime};
use crate::protocol::backend::{BackendMessage, BackendMessageType};
use crate::protocol::frontend::Terminate;
use crate::{
protocol::backend::{BackendMessage, BackendMessageType},
PgDatabaseError, PgNotice,
};
use crate::{PgDatabaseError, PgNotice};
/// Reads and writes messages to and from the PostgreSQL database server.
///