Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Dopplerian committed Apr 15, 2024
1 parent fe69c66 commit 201bc3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
12 changes: 6 additions & 6 deletions fang/src/asynk/async_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ use std::env;

use super::backend_sqlx::BackendSqlX;

async fn get_backend(
async fn get_pool(
kind: AnyKind,
_uri: &str,
_max_connections: u32,
) -> Result<(BackendSqlX, InternalPool), AsyncQueueError> {
) -> Result<InternalPool, AsyncQueueError> {
match kind {
#[cfg(feature = "asynk-postgres")]
AnyKind::Postgres => {
Expand All @@ -252,7 +252,7 @@ async fn get_backend(
.connect(_uri)
.await?;

Ok((BackendSqlX::Pg, InternalPool::Pg(pool)))
Ok(InternalPool::Pg(pool))
}
#[cfg(feature = "asynk-mysql")]
AnyKind::MySql => {
Expand All @@ -261,7 +261,7 @@ async fn get_backend(
.connect(_uri)
.await?;

Ok((BackendSqlX::MySql, InternalPool::MySql(pool)))
Ok(InternalPool::MySql(pool))
}
#[cfg(feature = "asynk-sqlite")]
AnyKind::Sqlite => {
Expand All @@ -270,7 +270,7 @@ async fn get_backend(
.connect(_uri)
.await?;

Ok((BackendSqlX::Sqlite, InternalPool::Sqlite(pool)))
Ok(InternalPool::Sqlite(pool))
}
#[allow(unreachable_patterns)]
_ => panic!("Not a valid backend"),
Expand All @@ -293,7 +293,7 @@ impl AsyncQueue {

let kind: AnyKind = self.uri.parse::<AnyConnectOptions>()?.kind();

let (backend, pool) = get_backend(kind, &self.uri, self.max_pool_size).await?;
let pool = get_pool(kind, &self.uri, self.max_pool_size).await?;

self.pool = Some(pool);
self.connected = true;
Expand Down
6 changes: 2 additions & 4 deletions fang/src/asynk/backend_sqlx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl BackendSqlX {
_pool: &InternalPool,
_params: QueryParams<'_>,
) -> Result<Res, AsyncQueueError> {
match self {
match *self {
#[cfg(feature = "asynk-postgres")]
BackendSqlX::Pg => {
BackendSqlXPg::execute_query(_query, _pool.unwrap_pg_pool(), _params).await
Expand All @@ -105,20 +105,18 @@ impl BackendSqlX {
BackendSqlX::MySql => {
BackendSqlXMySQL::execute_query(_query, _pool.unwrap_mysql_pool(), _params).await
}
_ => unreachable!(),
}
}

// I think it is useful to have this method, although it is not used
pub(crate) fn _name(&self) -> &str {
match self {
match *self {
#[cfg(feature = "asynk-postgres")]
BackendSqlX::Pg => BackendSqlXPg::_name(),
#[cfg(feature = "asynk-sqlite")]
BackendSqlX::Sqlite => BackendSqlXSQLite::_name(),
#[cfg(feature = "asynk-mysql")]
BackendSqlX::MySql => BackendSqlXMySQL::_name(),
_ => unreachable!(),
}
}
}
Expand Down

0 comments on commit 201bc3b

Please sign in to comment.