diff options
author | FxQnLr <[email protected]> | 2024-03-05 13:16:18 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-03-05 13:16:18 +0100 |
commit | 8dca7e83519b6c3531653cdedf60b2a14e1035b7 (patch) | |
tree | 0180a452dd354b067470618e6dbdc330649287cb /src/db.rs | |
parent | f0dc13f907a72ffef44f89b5e197567db129b020 (diff) | |
parent | 85c63c2ca8448428e2db93cb9d4f284a4e314ed7 (diff) | |
download | webol-8dca7e83519b6c3531653cdedf60b2a14e1035b7.tar webol-8dca7e83519b6c3531653cdedf60b2a14e1035b7.tar.gz webol-8dca7e83519b6c3531653cdedf60b2a14e1035b7.zip |
Merge pull request #22 from FxQnLr/0.3.3
0.3.3
Diffstat (limited to 'src/db.rs')
-rw-r--r-- | src/db.rs | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -1,6 +1,7 @@ | |||
1 | use serde::Serialize; | 1 | use serde::Serialize; |
2 | use sqlx::{PgPool, postgres::PgPoolOptions, types::{ipnetwork::IpNetwork, mac_address::MacAddress}}; | 2 | use sqlx::{PgPool, postgres::PgPoolOptions, types::{ipnetwork::IpNetwork, mac_address::MacAddress}}; |
3 | use tracing::{debug, info}; | 3 | use tracing::{debug, info}; |
4 | use utoipa::ToSchema; | ||
4 | 5 | ||
5 | #[derive(Serialize, Debug)] | 6 | #[derive(Serialize, Debug)] |
6 | pub struct Device { | 7 | pub 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)] | ||
17 | pub 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 | |||
14 | pub async fn init_db_pool(db_url: &str) -> PgPool { | 25 | pub 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 | ||