aboutsummaryrefslogtreecommitdiff
path: root/src/db.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/db.rs')
-rw-r--r--src/db.rs37
1 files changed, 0 insertions, 37 deletions
diff --git a/src/db.rs b/src/db.rs
deleted file mode 100644
index a2b2009..0000000
--- a/src/db.rs
+++ /dev/null
@@ -1,37 +0,0 @@
1use serde::Serialize;
2use sqlx::{PgPool, postgres::PgPoolOptions, types::{ipnetwork::IpNetwork, mac_address::MacAddress}};
3use tracing::{debug, info};
4use utoipa::ToSchema;
5
6#[derive(Serialize, Debug)]
7pub struct Device {
8 pub id: String,
9 pub mac: MacAddress,
10 pub broadcast_addr: String,
11 pub ip: IpNetwork,
12 pub times: Option<Vec<i64>>
13}
14
15#[derive(ToSchema)]
16#[schema(as = Device)]
17pub struct DeviceSchema {
18 pub id: String,
19 pub mac: String,
20 pub broadcast_addr: String,
21 pub ip: String,
22 pub times: Option<Vec<i64>>
23}
24
25pub async fn init_db_pool(db_url: &str) -> PgPool {
26 debug!("attempt to connect dbPool to '{}'", db_url);
27
28 let pool = PgPoolOptions::new()
29 .max_connections(5)
30 .connect(db_url)
31 .await
32 .unwrap();
33
34 info!("dbPool successfully connected to '{}'", db_url);
35
36 pool
37}