Skip to content

Commit 6e27bd2

Browse files
committed
feat: migrate to edition 2024
1 parent d3bc0a5 commit 6e27bd2

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "sql-studio"
33
version = "0.1.35"
4-
edition = "2021"
4+
edition = "2024"
55
repository = "https://github.com/frectonz/sql-studio"
66
description = "Single binary, single command SQL Database Explorer."
77
authors = ["frectonz"]

src/main.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,13 @@ async fn main() -> color_eyre::Result<()> {
175175

176176
let api = warp::path("api").and(handlers::routes(db, args.no_shutdown, shutdown_tx));
177177
let homepage = statics::homepage(index_html.clone());
178-
let statics = statics::routes(match args.base_path.as_ref() {
179-
Some(base) => base,
180-
None => "",
181-
});
178+
let statics = statics::routes(
179+
match args.base_path.as_ref() {
180+
Some(base) => base,
181+
None => "",
182+
}
183+
.to_owned(),
184+
);
182185

183186
let routes = api
184187
.or(statics)
@@ -191,7 +194,7 @@ async fn main() -> color_eyre::Result<()> {
191194
tracing::info!("tried to open in browser: {res:?}");
192195
}
193196

194-
let routes = if let Some(base_path) = args.base_path {
197+
let routes = if let Some(ref base_path) = args.base_path {
195198
let path = base_path
196199
.strip_prefix("/")
197200
.ok_or_eyre("base path should have a forward slash (/) prefix")?;
@@ -222,13 +225,13 @@ mod statics {
222225
use std::path::Path;
223226

224227
use color_eyre::eyre::OptionExt;
225-
use include_dir::{include_dir, Dir};
228+
use include_dir::{Dir, include_dir};
226229
use warp::{
230+
Filter,
227231
http::{
228-
header::{CACHE_CONTROL, CONTENT_TYPE},
229232
Response,
233+
header::{CACHE_CONTROL, CONTENT_TYPE},
230234
},
231-
Filter,
232235
};
233236

234237
static STATIC_DIR: Dir = include_dir!("ui/dist");
@@ -289,7 +292,7 @@ mod statics {
289292
}
290293

291294
pub fn routes(
292-
base_path_replacer: &str,
295+
base_path_replacer: String,
293296
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
294297
let base_path_replacer = base_path_replacer.to_owned();
295298
warp::path::tail()
@@ -429,7 +432,7 @@ mod sqlite {
429432
use std::{collections::HashMap, path::Path, sync::Arc, time::Duration};
430433
use tokio_rusqlite::{Connection, OpenFlags};
431434

432-
use crate::{helpers, responses, Database, ROWS_PER_PAGE, SAMPLE_DB};
435+
use crate::{Database, ROWS_PER_PAGE, SAMPLE_DB, helpers, responses};
433436

434437
#[derive(Clone)]
435438
pub struct Db {
@@ -839,7 +842,7 @@ mod libsql {
839842
use futures::{StreamExt, TryStreamExt};
840843
use libsql::Builder;
841844

842-
use crate::{helpers, responses, Database, ROWS_PER_PAGE};
845+
use crate::{Database, ROWS_PER_PAGE, helpers, responses};
843846

844847
#[derive(Clone)]
845848
pub struct Db {
@@ -1400,9 +1403,8 @@ mod postgres {
14001403
use tokio_postgres::{Client, NoTls};
14011404

14021405
use crate::{
1403-
helpers,
1406+
Database, ROWS_PER_PAGE, helpers,
14041407
responses::{self, Count},
1405-
Database, ROWS_PER_PAGE,
14061408
};
14071409

14081410
#[derive(Clone)]
@@ -1922,12 +1924,11 @@ mod mysql {
19221924
use std::time::Duration;
19231925

19241926
use color_eyre::eyre::OptionExt;
1925-
use mysql_async::{prelude::*, Pool};
1927+
use mysql_async::{Pool, prelude::*};
19261928

19271929
use crate::{
1928-
helpers,
1930+
Database, ROWS_PER_PAGE, helpers,
19291931
responses::{self, Count},
1930-
Database, ROWS_PER_PAGE,
19311932
};
19321933

19331934
#[derive(Clone)]
@@ -2367,9 +2368,8 @@ mod duckdb {
23672368
};
23682369

23692370
use crate::{
2370-
helpers,
2371+
Database, ROWS_PER_PAGE, helpers,
23712372
responses::{self, Count},
2372-
Database, ROWS_PER_PAGE,
23732373
};
23742374

23752375
#[derive(Clone)]
@@ -2771,8 +2771,8 @@ mod clickhouse {
27712771
use std::time::Duration;
27722772

27732773
use crate::{
2774-
responses::{self, Count},
27752774
Database, ROWS_PER_PAGE,
2775+
responses::{self, Count},
27762776
};
27772777

27782778
#[derive(Clone)]
@@ -3168,9 +3168,9 @@ mod mssql {
31683168
use tokio::{net::TcpStream, sync::Mutex};
31693169

31703170
use crate::{
3171+
Database, ROWS_PER_PAGE,
31713172
helpers::{self, mssql_value_to_json},
31723173
responses::{self, Count},
3173-
Database, ROWS_PER_PAGE,
31743174
};
31753175

31763176
#[derive(Clone)]
@@ -3900,17 +3900,17 @@ mod handlers {
39003900
use tokio::sync::mpsc;
39013901
use warp::Filter;
39023902

3903-
use crate::{rejections, responses::Metadata, Database};
3903+
use crate::{Database, rejections, responses::Metadata};
39043904

39053905
fn with_state<T: Clone + Send>(
39063906
state: &T,
3907-
) -> impl Filter<Extract = (T,), Error = std::convert::Infallible> + Clone {
3907+
) -> impl Filter<Extract = (T,), Error = std::convert::Infallible> + Clone + use<T> {
39083908
let state = state.to_owned();
39093909
warp::any().map(move || state.clone())
39103910
}
39113911

39123912
pub fn routes(
3913-
db: impl Database,
3913+
db: impl Database + 'static,
39143914
no_shutdown: bool,
39153915
shutdown_signal: mpsc::Sender<()>,
39163916
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {

0 commit comments

Comments
 (0)