types/
db.rs

1//! All database related types.
2
3use chrono::DateTime;
4use postgresql_embedded::PostgreSQL;
5use sqlx::FromRow;
6use testcontainers::{ContainerAsync, GenericImage};
7
8use crate::cv::Gps;
9
10#[derive(Debug)]
11pub enum PostgresTypes {
12    Embedded(PostgreSQL),
13    Container(ContainerAsync<GenericImage>),
14}
15
16/// A GPS coordinate struct which is used when interacting with the database.
17#[derive(FromRow, Clone)]
18pub struct GPSRow {
19    pub timestamp: i64,
20    pub lat: f64,
21    pub long: f64,
22    pub alt: f64,
23    pub heading: f64,
24}
25
26impl From<GPSRow> for Gps {
27    fn from(val: GPSRow) -> Self {
28        Gps {
29            lat: val.lat,
30            long: val.long,
31            alt: val.alt,
32            heading: val.heading,
33            time: DateTime::from_timestamp_millis(val.timestamp).unwrap(),
34        }
35    }
36}
37
38/// A detected object struct which is used when interacting with the database.
39#[derive(FromRow, Clone)]
40pub struct ObjectRow {
41    pub lat: f64,
42    pub long: f64,
43    pub class: i32,
44    pub max_confidence: f32,
45    pub num_detections: i32,
46    pub original_filepath: String,
47}