changeset 9:71c5459ec0cc

Clean up imports and features
author Lewin Bormann <lbo@spheniscida.de>
date Sun, 10 Jul 2022 09:51:36 -0700
parents 6e4ad5da0f58
children d7b0a2a2e011
files Cargo.toml src/main.rs
diffstat 2 files changed, 9 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Cargo.toml	Sun Jul 10 09:29:04 2022 -0700
+++ b/Cargo.toml	Sun Jul 10 09:51:36 2022 -0700
@@ -11,7 +11,7 @@
 env_logger = "0.9.0"
 log = "0.4.17"
 rocket = { version = "0.5.0-rc.2", features = ["secrets"] }
-rocket_db_pools = { version = "0.1.0-rc.2", features = ["sqlx_sqlite", "sqlx_postgres"] }
+rocket_db_pools = { version = "0.1.0-rc.2" }
 rocket_dyn_templates = { version = "0.1.0-rc.2", features = ["handlebars"] }
 sha256 = "1.0.3"
 time = "0.3.11"
@@ -19,5 +19,6 @@
 
 [features]
 default = ["sqlite"]
-sqlite = []
-postgres = []
+sqlite = ["rocket_db_pools/sqlx_sqlite"]
+postgres = ["rocket_db_pools/sqlx_postgres"]
+
--- a/src/main.rs	Sun Jul 10 09:29:04 2022 -0700
+++ b/src/main.rs	Sun Jul 10 09:51:36 2022 -0700
@@ -2,17 +2,14 @@
 use either::Either;
 use log::{debug, error, info, Level};
 
-#[macro_use]
-use rocket::{self};
-
 use rocket::form::Form;
 use rocket::fs::NamedFile;
-use rocket::http::{Cookie, CookieJar, Header, HeaderMap, Status};
+use rocket::http::{Cookie, CookieJar, HeaderMap, Status};
 use rocket::request::{self, FlashMessage, FromRequest, Outcome, Request};
-use rocket::response::{self, Flash, Redirect, Responder, Response};
+use rocket::response::{self, Flash, Redirect, Responder};
 
 use rocket_db_pools::sqlx::{
-    self, pool::PoolConnection, Executor, PgPool, Postgres, Row, Sqlite, SqlitePool, Statement,
+    self, Executor, Row, Sqlite, SqlitePool,
 };
 use rocket_db_pools::{Connection, Database, Pool};
 
@@ -21,8 +18,6 @@
 use std::net::IpAddr;
 use std::path::Path;
 
-use tokio::fs::{self, File};
-
 #[cfg(feature = "sqlite")]
 type DBType = Sqlite;
 #[cfg(feature = "sqlite")]
@@ -30,6 +25,8 @@
 
 // Current SQL queries don't work with postgres.
 #[cfg(feature = "postgres")]
+use rocket_db_pools::sqlx::{PgPool, Postgres};
+#[cfg(feature = "postgres")]
 type DBType = Postgres;
 #[cfg(feature = "postgres")]
 type PoolType = PgPool;