diff options
author | FxQnLr <[email protected]> | 2024-03-04 21:37:55 +0100 |
---|---|---|
committer | FxQnLr <[email protected]> | 2024-03-04 21:37:55 +0100 |
commit | 0a058ba2064d323451462a79c71580dea7d8ec8c (patch) | |
tree | 3e0a5a8c2d48aac8b1ff1720455db47a0c50386a /src/db.rs | |
parent | 0920c86de3523785b5f4ac67e2090f0736f9fcb2 (diff) | |
download | webol-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.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 | ||