summaryrefslogtreecommitdiff
path: root/src/db.rs
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2024-03-04 21:37:55 +0100
committerFxQnLr <[email protected]>2024-03-04 21:37:55 +0100
commit0a058ba2064d323451462a79c71580dea7d8ec8c (patch)
tree3e0a5a8c2d48aac8b1ff1720455db47a0c50386a /src/db.rs
parent0920c86de3523785b5f4ac67e2090f0736f9fcb2 (diff)
downloadwebol-0a058ba2064d323451462a79c71580dea7d8ec8c.tar
webol-0a058ba2064d323451462a79c71580dea7d8ec8c.tar.gz
webol-0a058ba2064d323451462a79c71580dea7d8ec8c.zip
Closes #19. Added OpenApi through `utoipa`
Diffstat (limited to 'src/db.rs')
-rw-r--r--src/db.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/db.rs b/src/db.rs
index 47e907d..a2b2009 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -1,6 +1,7 @@
1use serde::Serialize; 1use serde::Serialize;
2use sqlx::{PgPool, postgres::PgPoolOptions, types::{ipnetwork::IpNetwork, mac_address::MacAddress}}; 2use sqlx::{PgPool, postgres::PgPoolOptions, types::{ipnetwork::IpNetwork, mac_address::MacAddress}};
3use tracing::{debug, info}; 3use tracing::{debug, info};
4use utoipa::ToSchema;
4 5
5#[derive(Serialize, Debug)] 6#[derive(Serialize, Debug)]
6pub struct Device { 7pub struct Device {
@@ -11,6 +12,16 @@ pub struct Device {
11 pub times: Option<Vec<i64>> 12 pub times: Option<Vec<i64>>
12} 13}
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
14pub async fn init_db_pool(db_url: &str) -> PgPool { 25pub async fn init_db_pool(db_url: &str) -> PgPool {
15 debug!("attempt to connect dbPool to '{}'", db_url); 26 debug!("attempt to connect dbPool to '{}'", db_url);
16 27