mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-29 21:00:54 +00:00
fix(mysql): remove a few unused imports and add dyn usage
This commit is contained in:
parent
1dc106f053
commit
3caa5e91f7
@ -42,7 +42,7 @@ base64 = "0.13.0"
|
||||
rand = "0.7"
|
||||
|
||||
[dev-dependencies]
|
||||
sqlx-core = { version = "0.6.0-pre", path = "../sqlx-core", features = ["_mock", "tokio"] }
|
||||
sqlx-core = { version = "0.6.0-pre", path = "../sqlx-core", features = ["_mock"] }
|
||||
futures-executor = "0.3.8"
|
||||
anyhow = "1.0.37"
|
||||
tokio = { version = "1.0", features = ["full"] }
|
||||
@ -51,4 +51,4 @@ once_cell = "1.5.2"
|
||||
[[test]]
|
||||
name = "mysql-connection"
|
||||
path = "tests/connection.rs"
|
||||
required-features = ["async"]
|
||||
required-features = ["async", "sqlx-core/tokio"]
|
||||
|
||||
@ -25,6 +25,7 @@ mod ping;
|
||||
pub struct MySqlConnection<Rt: Runtime> {
|
||||
stream: MySqlStream<Rt>,
|
||||
connection_id: u32,
|
||||
|
||||
closed: bool,
|
||||
|
||||
// the capability flags are used by the client and server to indicate which
|
||||
@ -60,6 +61,11 @@ impl<Rt: Runtime> MySqlConnection<Rt> {
|
||||
| Capabilities::DEPRECATE_EOF,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the server-assigned connection identifier associated with this connection.
|
||||
pub fn id(&self) -> u32 {
|
||||
self.connection_id
|
||||
}
|
||||
}
|
||||
|
||||
impl<Rt: Runtime> Debug for MySqlConnection<Rt> {
|
||||
|
||||
@ -102,7 +102,11 @@ 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!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,7 +114,11 @@ 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!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,7 +147,11 @@ 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!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,6 +159,10 @@ 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!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ use sqlx_core::io::Deserialize;
|
||||
use sqlx_core::Result;
|
||||
|
||||
use crate::protocol::{AuthSwitch, Capabilities, ResultPacket};
|
||||
use crate::{MySqlClientError, MySqlDatabaseError};
|
||||
use crate::MySqlClientError;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum AuthResponse {
|
||||
|
||||
@ -28,7 +28,7 @@ impl Deserialize<'_> for AuthSwitch {
|
||||
|
||||
let plugin_data = buf.chain(Bytes::new());
|
||||
|
||||
let plugin = AuthPlugin::parse(&*name)?;
|
||||
let plugin = <dyn AuthPlugin>::parse(&*name)?;
|
||||
|
||||
Ok(Self { plugin, plugin_data })
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ impl Deserialize<'_> for Handshake {
|
||||
status,
|
||||
auth_plugin_data: auth_plugin_data_1.chain(auth_plugin_data_2),
|
||||
auth_plugin: auth_plugin_name
|
||||
.map(|name| AuthPlugin::parse(&name))
|
||||
.map(|name| <dyn AuthPlugin>::parse(&name))
|
||||
.transpose()?
|
||||
.unwrap_or_else(|| Box::new(NativeAuthPlugin)),
|
||||
})
|
||||
|
||||
@ -4,7 +4,7 @@ use sqlx_core::Result;
|
||||
|
||||
use super::{Capabilities, ResultPacket};
|
||||
use crate::io::MySqlBufExt;
|
||||
use crate::{MySqlClientError, MySqlDatabaseError};
|
||||
use crate::MySqlClientError;
|
||||
|
||||
/// The query-response packet is a meta-packet that starts with one of:
|
||||
///
|
||||
|
||||
@ -7,7 +7,7 @@ use sqlx_core::net::Stream as NetStream;
|
||||
use sqlx_core::{Result, Runtime};
|
||||
|
||||
use crate::protocol::{MaybeCommand, Packet, Quit};
|
||||
use crate::{MySqlClientError, MySqlDatabaseError};
|
||||
use crate::MySqlClientError;
|
||||
|
||||
/// Reads and writes packets to and from the MySQL database server.
|
||||
///
|
||||
|
||||
2
x.py
2
x.py
@ -235,7 +235,7 @@ def run_integration_test(project: str, database: str):
|
||||
"-q" if argv.quiet else None,
|
||||
"--message-format", "human" if argv.verbose else "short",
|
||||
"--manifest-path", f"{project}/Cargo.toml",
|
||||
"--features", "async",
|
||||
"--features", "async,sqlx-core/tokio",
|
||||
*unknown,
|
||||
] if x], env=env, cwd=project_dir, comment=f"integration test {project}", tag=tag)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user