summaryrefslogtreecommitdiff
path: root/src/db.rs
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2024-04-11 09:20:04 +0200
committerGitHub <[email protected]>2024-04-11 09:20:04 +0200
commit6b05d1a437a49db98056de7b029923e8aedf1a5a (patch)
treebc70f14cae1760e91369705273904c0de1bfbf75 /src/db.rs
parent907e5cb5bc48899b444f7fedd85af7b5974d9a2e (diff)
parent2476e182f61d209768635e8eca6e75b4acfbd007 (diff)
downloadwebol-6b05d1a437a49db98056de7b029923e8aedf1a5a.tar
webol-6b05d1a437a49db98056de7b029923e8aedf1a5a.tar.gz
webol-6b05d1a437a49db98056de7b029923e8aedf1a5a.zip
Merge pull request #32 from FxQnLr/0.4.0
0.4.0
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}